// @generated by ferrovue from client/components/types.ts. Do not edit: change the type files and run // `ferrovue`. //! The types components import from shared `.ts` files, written once so that components passing //! them to one another agree on them. use std::borrow::Cow; use ferrovue as fv; /// `Book` in `client/components/types.ts`. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Book<'a> { pub id: Cow<'a, str>, pub title: Cow<'a, str>, pub author: Cow<'a, str>, pub year: i64, } impl<'a> Book<'a> { /// Book with its required fields. pub fn new(id: impl Into>, title: impl Into>, author: impl Into>, year: i64) -> Self { Book { id: id.into(), title: title.into(), author: author.into(), year } } } /// `Review` in `client/components/types.ts`. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Review<'a> { pub reader: Cow<'a, str>, pub stars: i64, pub text: Cow<'a, str>, #[serde(default, skip_serializing_if = "Option::is_none", with = "fv::date::opt_date_prop")] pub posted: Option, } impl<'a> Review<'a> { /// Review with its required fields, every optional one absent. pub fn new(reader: impl Into>, stars: i64, text: impl Into>) -> Self { Review { reader: reader.into(), stars, text: text.into(), posted: None } } /// Set `posted`, which is absent otherwise. pub fn posted(mut self, posted: ferrovue::date::JsDate) -> Self { self.posted = Some(posted); self } } /// `Stock` in `client/components/types.ts`. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Stock<'a> { pub copies: i64, pub warehouse: Cow<'a, str>, #[serde(default, skip_serializing_if = "Option::is_none", with = "fv::date::opt_date_prop")] pub counted: Option, } impl<'a> Stock<'a> { /// Stock with its required fields, every optional one absent. pub fn new(copies: i64, warehouse: impl Into>) -> Self { Stock { copies, warehouse: warehouse.into(), counted: None } } /// Set `counted`, which is absent otherwise. pub fn counted(mut self, counted: ferrovue::date::JsDate) -> Self { self.counted = Some(counted); self } } /// `Warehouse` in `client/components/types.ts`. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Warehouse<'a> { pub city: Cow<'a, str>, pub days: i64, } impl<'a> Warehouse<'a> { /// Warehouse with its required fields. pub fn new(city: impl Into>, days: i64) -> Self { Warehouse { city: city.into(), days } } }