// @generated by ferrovue from client/components/Pick.vue. Do not edit: change the `.vue` file and run // `ferrovue`. use std::borrow::Cow; use ferrovue as fv; /// The component's name, as `data-island` carries it. pub const NAME: &str = "Pick"; /// The props `Pick.vue` declares. #[derive(Debug, Clone, serde::Serialize)] #[cfg_attr(test, derive(serde::Deserialize))] pub struct Props<'a> { pub book: super::types::Book<'a>, pub note: Cow<'a, str>, } impl<'a> Props<'a> { /// Props with its required fields. pub fn new(book: super::types::Book<'a>, note: impl Into>) -> Self { Props { book, note: note.into() } } } /// Write the component's server render into `out`. /// /// # Panics /// /// With the message of the refusal [`try_render`] returns. pub fn render(out: &mut String, props: &Props<'_>) { fv::render::rendered(try_render(out, props)); } /// [`render`], returning the refusal of a render that cannot write what Vue writes for these /// props, such as a date string browsers read differently: a server answers it with an error. /// /// # Errors /// /// The first [`fv::render::Refused`] the render met; `out` then holds what was written before it. pub fn try_render(out: &mut String, props: &Props<'_>) -> Result<(), fv::render::Refused> { out.reserve( 115 + props.book.id.len() + props.book.title.len() + props.book.author.len() + props.note.len() ); if props.book.id.is_empty() { out.push_str("

"); } else { out.push_str("

"); } fv::core::escape_into(out, &props.book.title); out.push_str("

by "); fv::core::escape_into(out, &props.book.author); out.push_str(" ("); fv::core::push_int(out, props.book.year); out.push_str(")

"); fv::core::escape_into(out, &props.note); out.push_str("
"); super::add_to_basket::try_render(out, &super::add_to_basket::Props { id: Cow::Borrowed(&*props.book.id), title: Cow::Borrowed(&*props.book.title), })?; out.push_str("
"); Ok(()) } /// The component's markup, for a maud page that shows it without hydrating it. pub fn html<'p, 'a>(props: &'p Props<'a>) -> fv::html::Html<'p, Props<'a>> { fv::html::Html::markup_fallible(props, render, try_render) } /// The component as an island the client hydrates. pub fn island<'p, 'a>(props: &'p Props<'a>) -> fv::html::Html<'p, Props<'a>> { fv::html::Html::island_fallible(NAME, props, render, try_render) } /// [`html`], holding the props: a handler that builds them can return it. pub fn into_html<'a>(props: Props<'a>) -> fv::html::Html<'a, Props<'a>> { fv::html::Html::markup_owned_fallible(props, render, try_render) } /// [`island`], holding the props. pub fn into_island<'a>(props: Props<'a>) -> fv::html::Html<'a, Props<'a>> { fv::html::Html::island_owned_fallible(NAME, props, render, try_render) }