// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.notebook.getSuggestedNotebooks // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct GetSuggestedNotebooks { ///(default: 20, min: 1, max: 50) #[serde(skip_serializing_if = "std::option::Option::is_none")] pub limit: std::option::Option, } pub mod get_suggested_notebooks_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed {} /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty {} /// Marker types for field names #[allow(non_camel_case_types)] pub mod members {} } /// Builder for constructing an instance of this type pub struct GetSuggestedNotebooksBuilder { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: (::core::option::Option,), } impl GetSuggestedNotebooks { /// Create a new builder for this type pub fn new() -> GetSuggestedNotebooksBuilder { GetSuggestedNotebooksBuilder::new() } } impl GetSuggestedNotebooksBuilder { /// Create a new builder with all fields unset pub fn new() -> Self { GetSuggestedNotebooksBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None,), } } } impl GetSuggestedNotebooksBuilder { /// Set the `limit` field (optional) pub fn limit(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `limit` field to an Option value (optional) pub fn maybe_limit(mut self, value: Option) -> Self { self.__unsafe_private_named.0 = value; self } } impl GetSuggestedNotebooksBuilder where S: get_suggested_notebooks_state::State, { /// Build the final struct pub fn build(self) -> GetSuggestedNotebooks { GetSuggestedNotebooks { limit: self.__unsafe_private_named.0, } } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct GetSuggestedNotebooksOutput<'a> { #[serde(borrow)] pub notebooks: Vec< crate::sh_weaver::notebook::get_suggested_notebooks::SuggestedNotebook<'a>, >, } /// Response type for ///sh.weaver.notebook.getSuggestedNotebooks pub struct GetSuggestedNotebooksResponse; impl jacquard_common::xrpc::XrpcResp for GetSuggestedNotebooksResponse { const NSID: &'static str = "sh.weaver.notebook.getSuggestedNotebooks"; const ENCODING: &'static str = "application/json"; type Output<'de> = GetSuggestedNotebooksOutput<'de>; type Err<'de> = jacquard_common::xrpc::GenericError<'de>; } impl jacquard_common::xrpc::XrpcRequest for GetSuggestedNotebooks { const NSID: &'static str = "sh.weaver.notebook.getSuggestedNotebooks"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = GetSuggestedNotebooksResponse; } /// Endpoint type for ///sh.weaver.notebook.getSuggestedNotebooks pub struct GetSuggestedNotebooksRequest; impl jacquard_common::xrpc::XrpcEndpoint for GetSuggestedNotebooksRequest { const PATH: &'static str = "/xrpc/sh.weaver.notebook.getSuggestedNotebooks"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request<'de> = GetSuggestedNotebooks; type Response = GetSuggestedNotebooksResponse; } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct SuggestedNotebook<'a> { #[serde(borrow)] pub notebook: crate::sh_weaver::notebook::NotebookView<'a>, #[serde(borrow)] pub reason: crate::sh_weaver::notebook::get_suggested_notebooks::SuggestionReason< 'a, >, /// Appview-computed relevance score. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub score: std::option::Option, } pub mod suggested_notebook_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Notebook; type Reason; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Notebook = Unset; type Reason = Unset; } ///State transition - sets the `notebook` field to Set pub struct SetNotebook(PhantomData S>); impl sealed::Sealed for SetNotebook {} impl State for SetNotebook { type Notebook = Set; type Reason = S::Reason; } ///State transition - sets the `reason` field to Set pub struct SetReason(PhantomData S>); impl sealed::Sealed for SetReason {} impl State for SetReason { type Notebook = S::Notebook; type Reason = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `notebook` field pub struct notebook(()); ///Marker type for the `reason` field pub struct reason(()); } } /// Builder for constructing an instance of this type pub struct SuggestedNotebookBuilder<'a, S: suggested_notebook_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option< crate::sh_weaver::notebook::get_suggested_notebooks::SuggestionReason<'a>, >, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> SuggestedNotebook<'a> { /// Create a new builder for this type pub fn new() -> SuggestedNotebookBuilder<'a, suggested_notebook_state::Empty> { SuggestedNotebookBuilder::new() } } impl<'a> SuggestedNotebookBuilder<'a, suggested_notebook_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { SuggestedNotebookBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SuggestedNotebookBuilder<'a, S> where S: suggested_notebook_state::State, S::Notebook: suggested_notebook_state::IsUnset, { /// Set the `notebook` field (required) pub fn notebook( mut self, value: impl Into>, ) -> SuggestedNotebookBuilder<'a, suggested_notebook_state::SetNotebook> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); SuggestedNotebookBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SuggestedNotebookBuilder<'a, S> where S: suggested_notebook_state::State, S::Reason: suggested_notebook_state::IsUnset, { /// Set the `reason` field (required) pub fn reason( mut self, value: impl Into< crate::sh_weaver::notebook::get_suggested_notebooks::SuggestionReason<'a>, >, ) -> SuggestedNotebookBuilder<'a, suggested_notebook_state::SetReason> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); SuggestedNotebookBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: suggested_notebook_state::State> SuggestedNotebookBuilder<'a, S> { /// Set the `score` field (optional) pub fn score(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `score` field to an Option value (optional) pub fn maybe_score(mut self, value: Option) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> SuggestedNotebookBuilder<'a, S> where S: suggested_notebook_state::State, S::Notebook: suggested_notebook_state::IsSet, S::Reason: suggested_notebook_state::IsSet, { /// Build the final struct pub fn build(self) -> SuggestedNotebook<'a> { SuggestedNotebook { notebook: self.__unsafe_private_named.0.unwrap(), reason: self.__unsafe_private_named.1.unwrap(), score: self.__unsafe_private_named.2, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> SuggestedNotebook<'a> { SuggestedNotebook { notebook: self.__unsafe_private_named.0.unwrap(), reason: self.__unsafe_private_named.1.unwrap(), score: self.__unsafe_private_named.2, extra_data: Some(extra_data), } } } fn lexicon_doc_sh_weaver_notebook_getSuggestedNotebooks() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.getSuggestedNotebooks", ), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::XrpcQuery(::jacquard_lexicon::lexicon::LexXrpcQuery { description: None, parameters: Some( ::jacquard_lexicon::lexicon::LexXrpcQueryParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters { description: None, required: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("limit"), ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map }, }), ), output: None, errors: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("suggestedNotebook"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("notebook"), ::jacquard_common::smol_str::SmolStr::new_static("reason") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("notebook"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#notebookView", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("reason"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "#suggestionReason", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("score"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("suggestionReason"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "Why this notebook was suggested.", ), ), required: Some( vec![::jacquard_common::smol_str::SmolStr::new_static("type")], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "relatedAuthor", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#profileViewBasic", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "relatedList", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.graph.defs#listView", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "relatedNotebook", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#notebookView", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "relatedTags", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static("Tags that matched."), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("type"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SuggestedNotebook<'a> { fn nsid() -> &'static str { "sh.weaver.notebook.getSuggestedNotebooks" } fn def_name() -> &'static str { "suggestedNotebook" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notebook_getSuggestedNotebooks() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } /// Why this notebook was suggested. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct SuggestionReason<'a> { /// If followed-author, the author. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub related_author: std::option::Option< crate::sh_weaver::actor::ProfileViewBasic<'a>, >, /// If from-list, the list it's from. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub related_list: std::option::Option>, /// If similar-to-X, the notebook it's similar to. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub related_notebook: std::option::Option< crate::sh_weaver::notebook::NotebookView<'a>, >, /// Tags that matched. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub related_tags: std::option::Option>>, #[serde(borrow)] pub r#type: SuggestionReasonType<'a>, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SuggestionReasonType<'a> { SimilarTags, SimilarToLiked, SimilarToRead, FollowedAuthor, PopularInTag, Trending, FromList, Other(jacquard_common::CowStr<'a>), } impl<'a> SuggestionReasonType<'a> { pub fn as_str(&self) -> &str { match self { Self::SimilarTags => "similar-tags", Self::SimilarToLiked => "similar-to-liked", Self::SimilarToRead => "similar-to-read", Self::FollowedAuthor => "followed-author", Self::PopularInTag => "popular-in-tag", Self::Trending => "trending", Self::FromList => "from-list", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for SuggestionReasonType<'a> { fn from(s: &'a str) -> Self { match s { "similar-tags" => Self::SimilarTags, "similar-to-liked" => Self::SimilarToLiked, "similar-to-read" => Self::SimilarToRead, "followed-author" => Self::FollowedAuthor, "popular-in-tag" => Self::PopularInTag, "trending" => Self::Trending, "from-list" => Self::FromList, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for SuggestionReasonType<'a> { fn from(s: String) -> Self { match s.as_str() { "similar-tags" => Self::SimilarTags, "similar-to-liked" => Self::SimilarToLiked, "similar-to-read" => Self::SimilarToRead, "followed-author" => Self::FollowedAuthor, "popular-in-tag" => Self::PopularInTag, "trending" => Self::Trending, "from-list" => Self::FromList, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for SuggestionReasonType<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for SuggestionReasonType<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for SuggestionReasonType<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for SuggestionReasonType<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for SuggestionReasonType<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for SuggestionReasonType<'_> { type Output = SuggestionReasonType<'static>; fn into_static(self) -> Self::Output { match self { SuggestionReasonType::SimilarTags => SuggestionReasonType::SimilarTags, SuggestionReasonType::SimilarToLiked => SuggestionReasonType::SimilarToLiked, SuggestionReasonType::SimilarToRead => SuggestionReasonType::SimilarToRead, SuggestionReasonType::FollowedAuthor => SuggestionReasonType::FollowedAuthor, SuggestionReasonType::PopularInTag => SuggestionReasonType::PopularInTag, SuggestionReasonType::Trending => SuggestionReasonType::Trending, SuggestionReasonType::FromList => SuggestionReasonType::FromList, SuggestionReasonType::Other(v) => { SuggestionReasonType::Other(v.into_static()) } } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SuggestionReason<'a> { fn nsid() -> &'static str { "sh.weaver.notebook.getSuggestedNotebooks" } fn def_name() -> &'static str { "suggestionReason" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notebook_getSuggestedNotebooks() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }