pub struct ServerFnCall { /* private fields */ }Expand description
A parsed server function call.
Implementations§
Source§impl ServerFnCall
impl ServerFnCall
Sourcepub fn parse(
default_path: &str,
args: TokenStream2,
body: TokenStream2,
) -> Result<Self>
pub fn parse( default_path: &str, args: TokenStream2, body: TokenStream2, ) -> Result<Self>
Parse the arguments of a server function call.
#[proc_macro_attribute]
pub fn server(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
match ServerFnCall::parse(
"/api",
args.into(),
s.into(),
) {
Err(e) => e.to_compile_error().into(),
Ok(s) => s.to_token_stream().into(),
}
}Sourcepub fn get_args(&self) -> &ServerFnArgs
pub fn get_args(&self) -> &ServerFnArgs
Get a reference to the server function arguments.
Sourcepub fn get_args_mut(&mut self) -> &mut ServerFnArgs
pub fn get_args_mut(&mut self) -> &mut ServerFnArgs
Get a mutable reference to the server function arguments.
Sourcepub fn get_body(&self) -> &ServerFnBody
pub fn get_body(&self) -> &ServerFnBody
Get a reference to the server function body.
Sourcepub fn get_body_mut(&mut self) -> &mut ServerFnBody
pub fn get_body_mut(&mut self) -> &mut ServerFnBody
Get a mutable reference to the server function body.
Sourcepub fn default_server_fn_path(self, path: Option<Path>) -> Self
pub fn default_server_fn_path(self, path: Option<Path>) -> Self
Set the path to the server function crate.
Sourcepub fn default_server_type(self, server: Option<Type>) -> Self
pub fn default_server_type(self, server: Option<Type>) -> Self
Set the default server implementation.
Sourcepub fn default_protocol(self, protocol: Option<Type>) -> Self
pub fn default_protocol(self, protocol: Option<Type>) -> Self
Set the default protocol.
Sourcepub fn default_input_encoding(self, protocol: Option<Type>) -> Self
pub fn default_input_encoding(self, protocol: Option<Type>) -> Self
Set the default input http encoding. This will be used by Self::protocol
if no protocol or default protocol is set or if only the output encoding is set
Defaults to PostUrl
Sourcepub fn default_output_encoding(self, protocol: Option<Type>) -> Self
pub fn default_output_encoding(self, protocol: Option<Type>) -> Self
Set the default output http encoding. This will be used by Self::protocol
if no protocol or default protocol is set or if only the input encoding is set
Defaults to Json
Sourcepub fn client_type(&self) -> Type
pub fn client_type(&self) -> Type
Get the client type to use for the server function.
Sourcepub fn server_type(&self) -> Type
pub fn server_type(&self) -> Type
Get the server type to use for the server function.
Sourcepub fn server_fn_path(&self) -> Path
pub fn server_fn_path(&self) -> Path
Get the path to the server_fn crate.
Sourcepub fn http_encodings(&self) -> Option<(Type, Type)>
pub fn http_encodings(&self) -> Option<(Type, Type)>
Get the http input and output encodings for the server function if no protocol is set
Sourcepub fn docs(&self) -> TokenStream2
pub fn docs(&self) -> TokenStream2
Get the docs for the server function.
Sourcepub fn struct_name(&self) -> Ident
pub fn struct_name(&self) -> Ident
Get the name of the server function struct that will be submitted to inventory.
This will either be the name specified in the macro arguments or the PascalCase version of the function name.
Sourcepub fn submit_to_inventory(&self) -> TokenStream2
pub fn submit_to_inventory(&self) -> TokenStream2
Generate the code to submit the server function type to inventory.
Sourcepub fn server_fn_url(&self) -> TokenStream2
pub fn server_fn_url(&self) -> TokenStream2
Generate the server function’s URL. This will be the prefix path, then by the
module path if SERVER_FN_MOD_PATH is set, then the function name, and finally
a hash of the function name and location in the source code.
Trait Implementations§
Source§impl ToTokens for ServerFnCall
impl ToTokens for ServerFnCall
Source§fn to_tokens(&self, tokens: &mut TokenStream2)
fn to_tokens(&self, tokens: &mut TokenStream2)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for ServerFnCall
impl RefUnwindSafe for ServerFnCall
impl !Send for ServerFnCall
impl !Sync for ServerFnCall
impl Unpin for ServerFnCall
impl UnwindSafe for ServerFnCall
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.