marks
This commit is contained in:
parent
360675f6f9
commit
a320b99aa3
10 changed files with 79 additions and 44 deletions
|
|
@ -7,6 +7,8 @@ pub mod boards;
|
||||||
pub mod messages;
|
pub mod messages;
|
||||||
pub mod threads;
|
pub mod threads;
|
||||||
|
|
||||||
|
pub mod marks;
|
||||||
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod authors;
|
pub mod authors;
|
||||||
pub mod files;
|
pub mod files;
|
||||||
|
|
|
||||||
10
core/src/errors/marks.rs
Normal file
10
core/src/errors/marks.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
use eva::data;
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
pub struct NoSuchTag {}
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
pub struct NoSuchGenre {}
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
pub struct NoSuchBadge {}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
errors,
|
errors,
|
||||||
types::{Patch, True, author, file, game},
|
types::{Patch, True, author, file, game, mark},
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
@ -23,9 +23,9 @@ pub mod update {
|
||||||
pub description: Patch<Option<game::Description>>,
|
pub description: Patch<Option<game::Description>>,
|
||||||
pub slug: Patch<game::Slug>,
|
pub slug: Patch<game::Slug>,
|
||||||
pub thumbnail: Patch<Option<file::Id>>,
|
pub thumbnail: Patch<Option<file::Id>>,
|
||||||
pub genres: Patch<game::Genres>,
|
pub genres: Patch<mark::Genres>,
|
||||||
pub badges: Patch<game::Badges>,
|
pub badges: Patch<mark::Badges>,
|
||||||
pub tags: Patch<game::Tags>,
|
pub tags: Patch<mark::Tags>,
|
||||||
pub screenshots: Patch<game::Screenshots>,
|
pub screenshots: Patch<game::Screenshots>,
|
||||||
pub published: Patch<bool>,
|
pub published: Patch<bool>,
|
||||||
}
|
}
|
||||||
|
|
@ -53,9 +53,9 @@ pub mod search {
|
||||||
#[data]
|
#[data]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Marks {
|
pub struct Marks {
|
||||||
pub tags: Logic<game::Tag, 16>,
|
pub tags: Logic<mark::Tag, 16>,
|
||||||
pub genres: Logic<game::Genre, 16>,
|
pub genres: Logic<mark::Genre, 16>,
|
||||||
pub badges: Logic<game::Badge, 16>,
|
pub badges: Logic<mark::Badge, 16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type SortKey<K> = (K, game::Id);
|
type SortKey<K> = (K, game::Id);
|
||||||
|
|
@ -141,6 +141,10 @@ pub mod create {
|
||||||
pub description: Option<game::Description>,
|
pub description: Option<game::Description>,
|
||||||
pub thumbnail: Option<file::Id>,
|
pub thumbnail: Option<file::Id>,
|
||||||
pub author: author::Id,
|
pub author: author::Id,
|
||||||
|
#[serde(default)]
|
||||||
|
pub tags: mark::Tags,
|
||||||
|
#[serde(default)]
|
||||||
|
pub genres: mark::Genres,
|
||||||
pub slug: Option<game::Slug>,
|
pub slug: Option<game::Slug>,
|
||||||
pub vndb: Option<game::VndbId>,
|
pub vndb: Option<game::VndbId>,
|
||||||
pub release_date: Option<game::ReleaseDate>,
|
pub release_date: Option<game::ReleaseDate>,
|
||||||
|
|
@ -165,8 +169,8 @@ pub mod get {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Marks {
|
pub struct Marks {
|
||||||
pub tags: HashMap<game::Tag, str::CompactString>,
|
pub tags: HashMap<mark::Tag, str::CompactString>,
|
||||||
pub badges: HashMap<game::Badge, str::CompactString>,
|
pub badges: HashMap<mark::Badge, str::CompactString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::types::game;
|
use crate::types::mark;
|
||||||
|
|
||||||
use eva::{array, data, str};
|
use eva::{array, data, str};
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ pub mod add_tag {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Ok {
|
pub struct Ok {
|
||||||
pub id: game::Tag,
|
pub id: mark::Tag,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(error, display("_"))]
|
#[data(error, display("_"))]
|
||||||
|
|
@ -35,7 +35,7 @@ pub mod add_badge {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Ok {
|
pub struct Ok {
|
||||||
pub id: game::Badge,
|
pub id: mark::Badge,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(error, display("_"))]
|
#[data(error, display("_"))]
|
||||||
|
|
@ -52,7 +52,7 @@ pub mod list_genres {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Ok {
|
pub struct Ok {
|
||||||
pub genres: array::ImmutableHeap<game::Genre, MAX>,
|
pub genres: array::ImmutableHeap<mark::Genre, MAX>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(error, display("_"))]
|
#[data(error, display("_"))]
|
||||||
|
|
@ -69,7 +69,7 @@ pub mod list_badges {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Ok {
|
pub struct Ok {
|
||||||
pub badges: Vec<TextEntry<game::Badge>>,
|
pub badges: Vec<TextEntry<mark::Badge>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(error, display("_"))]
|
#[data(error, display("_"))]
|
||||||
|
|
@ -86,7 +86,7 @@ pub mod list_tags {
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
pub struct Ok {
|
pub struct Ok {
|
||||||
pub tags: Vec<TextEntry<game::Tag>>,
|
pub tags: Vec<TextEntry<mark::Tag>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(error, display("_"))]
|
#[data(error, display("_"))]
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,6 @@
|
||||||
use eva::{array, data, int, str, str::CompactString, time::Date};
|
use eva::{array, data, int, str, str::CompactString, time::Date};
|
||||||
|
|
||||||
use crate::types::{author, entity::define_eid, file, slug, user};
|
use crate::types::{author, entity::define_eid, file, mark, slug, user};
|
||||||
|
|
||||||
#[data]
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Tags(pub array::ImmutableHeap<Tag, 64>);
|
|
||||||
|
|
||||||
#[data]
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Genres(pub array::ImmutableHeap<Genre, 64>);
|
|
||||||
|
|
||||||
#[data]
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Badges(pub array::ImmutableHeap<Badge, 64>);
|
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -100,9 +88,9 @@ pub struct Game {
|
||||||
pub publication: Option<Publication>,
|
pub publication: Option<Publication>,
|
||||||
|
|
||||||
pub screenshots: Screenshots,
|
pub screenshots: Screenshots,
|
||||||
pub tags: Tags,
|
pub tags: mark::Tags,
|
||||||
pub genres: Genres,
|
pub genres: mark::Genres,
|
||||||
pub badges: Badges,
|
pub badges: mark::Badges,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[data(copy)]
|
#[data(copy)]
|
||||||
|
|
@ -129,17 +117,8 @@ pub struct Votes(pub u32);
|
||||||
define_eid! {
|
define_eid! {
|
||||||
/// ID of the game.
|
/// ID of the game.
|
||||||
pub struct Id(Game);
|
pub struct Id(Game);
|
||||||
|
|
||||||
/// ID of the tag.
|
|
||||||
pub struct Tag(Tag);
|
|
||||||
|
|
||||||
/// Game badge.
|
|
||||||
pub struct Badge(Badge);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[str(newtype, copy)]
|
|
||||||
pub struct Genre(pub slug::LowerSlug<15>);
|
|
||||||
|
|
||||||
/// Estimated time to read.
|
/// Estimated time to read.
|
||||||
#[int(u8, 0..=100)]
|
#[int(u8, 0..=100)]
|
||||||
pub enum TimeToReadHours {}
|
pub enum TimeToReadHours {}
|
||||||
|
|
|
||||||
26
core/src/types/mark.rs
Normal file
26
core/src/types/mark.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
use eva::{array, data, str};
|
||||||
|
|
||||||
|
use crate::types::{entity, slug};
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Tags(pub array::ImmutableHeap<Tag, 64>);
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Genres(pub array::ImmutableHeap<Genre, 64>);
|
||||||
|
|
||||||
|
#[data]
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Badges(pub array::ImmutableHeap<Badge, 64>);
|
||||||
|
|
||||||
|
#[str(newtype, copy)]
|
||||||
|
pub struct Genre(pub slug::LowerSlug<15>);
|
||||||
|
|
||||||
|
entity::define_eid! {
|
||||||
|
/// ID of the tag.
|
||||||
|
pub struct Tag(Tag);
|
||||||
|
|
||||||
|
/// Game badge.
|
||||||
|
pub struct Badge(Badge);
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ pub mod board;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
|
|
||||||
|
pub mod mark;
|
||||||
|
|
||||||
pub mod author;
|
pub mod author;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ impl Games for HttpClient {
|
||||||
slug,
|
slug,
|
||||||
vndb,
|
vndb,
|
||||||
release_date,
|
release_date,
|
||||||
|
tags,
|
||||||
|
genres,
|
||||||
}| {
|
}| {
|
||||||
(
|
(
|
||||||
"/games".into(),
|
"/games".into(),
|
||||||
|
|
@ -65,6 +67,8 @@ impl Games for HttpClient {
|
||||||
description,
|
description,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
author,
|
author,
|
||||||
|
tags,
|
||||||
|
genres,
|
||||||
slug,
|
slug,
|
||||||
vndb,
|
vndb,
|
||||||
release_date,
|
release_date,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::requests::status_code;
|
||||||
use viendesu_core::{
|
use viendesu_core::{
|
||||||
errors,
|
errors,
|
||||||
requests::games as reqs,
|
requests::games as reqs,
|
||||||
types::{Patch, author, file, game},
|
types::{Patch, author, file, game, mark},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[data]
|
#[data]
|
||||||
|
|
@ -15,9 +15,9 @@ pub struct Update {
|
||||||
pub description: Patch<Option<game::Description>>,
|
pub description: Patch<Option<game::Description>>,
|
||||||
pub slug: Patch<game::Slug>,
|
pub slug: Patch<game::Slug>,
|
||||||
pub thumbnail: Patch<Option<file::Id>>,
|
pub thumbnail: Patch<Option<file::Id>>,
|
||||||
pub genres: Patch<game::Genres>,
|
pub genres: Patch<mark::Genres>,
|
||||||
pub badges: Patch<game::Badges>,
|
pub badges: Patch<mark::Badges>,
|
||||||
pub tags: Patch<game::Tags>,
|
pub tags: Patch<mark::Tags>,
|
||||||
pub screenshots: Patch<game::Screenshots>,
|
pub screenshots: Patch<game::Screenshots>,
|
||||||
pub published: Patch<bool>,
|
pub published: Patch<bool>,
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +62,10 @@ pub struct Create {
|
||||||
pub thumbnail: Option<file::Id>,
|
pub thumbnail: Option<file::Id>,
|
||||||
pub author: author::Id,
|
pub author: author::Id,
|
||||||
pub slug: Option<game::Slug>,
|
pub slug: Option<game::Slug>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub tags: mark::Tags,
|
||||||
|
#[serde(default)]
|
||||||
|
pub genres: mark::Genres,
|
||||||
pub vndb: Option<game::VndbId>,
|
pub vndb: Option<game::VndbId>,
|
||||||
pub release_date: Option<game::ReleaseDate>,
|
pub release_date: Option<game::ReleaseDate>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,8 @@ fn games<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
tags,
|
||||||
|
genres,
|
||||||
author,
|
author,
|
||||||
slug,
|
slug,
|
||||||
vndb,
|
vndb,
|
||||||
|
|
@ -364,6 +366,8 @@ fn games<T: Types>(router: RouterScope<T>) -> RouterScope<T> {
|
||||||
thumbnail,
|
thumbnail,
|
||||||
author,
|
author,
|
||||||
slug,
|
slug,
|
||||||
|
tags,
|
||||||
|
genres,
|
||||||
vndb,
|
vndb,
|
||||||
release_date,
|
release_date,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue