ServerFnCall

Struct ServerFnCall 

Source
pub struct ServerFnCall { /* private fields */ }
Expand description

A parsed server function call.

Implementations§

Source§

impl ServerFnCall

Source

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(),
    }
}
Source

pub fn get_args(&self) -> &ServerFnArgs

Get a reference to the server function arguments.

Source

pub fn get_args_mut(&mut self) -> &mut ServerFnArgs

Get a mutable reference to the server function arguments.

Source

pub fn get_body(&self) -> &ServerFnBody

Get a reference to the server function body.

Source

pub fn get_body_mut(&mut self) -> &mut ServerFnBody

Get a mutable reference to the server function body.

Source

pub fn default_server_fn_path(self, path: Option<Path>) -> Self

Set the path to the server function crate.

Source

pub fn default_server_type(self, server: Option<Type>) -> Self

Set the default server implementation.

Source

pub fn default_protocol(self, protocol: Option<Type>) -> Self

Set the default protocol.

Source

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

Source

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

Source

pub fn client_type(&self) -> Type

Get the client type to use for the server function.

Source

pub fn server_type(&self) -> Type

Get the server type to use for the server function.

Source

pub fn server_fn_path(&self) -> Path

Get the path to the server_fn crate.

Source

pub fn http_encodings(&self) -> Option<(Type, Type)>

Get the http input and output encodings for the server function if no protocol is set

Source

pub fn protocol(&self) -> Type

Get the protocol to use for the server function.

Source

pub fn docs(&self) -> TokenStream2

Get the docs for the server function.

Source

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.

Source

pub fn submit_to_inventory(&self) -> TokenStream2

Generate the code to submit the server function type to inventory.

Source

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

Source§

fn to_tokens(&self, tokens: &mut TokenStream2)

Write self to the given TokenStream. Read more
Source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
Source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Spanned for T
where T: Spanned + ?Sized,

Source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.