pub(crate) struct FnSignature {
    pub kind: FnKind,
    pub span: Span,
    pub mod_path: String,
    pub ident: Ident,
    pub name: String,
    pub is_async: bool,
    pub receiver: Option<ReceiverArg>,
    pub args: Vec<NamedArg>,
    pub return_ty: TokenStream,
    pub looks_like_result: bool,
    pub docstring: String,
}

Fields§

§kind: FnKind§span: Span§mod_path: String§ident: Ident§name: String§is_async: bool§receiver: Option<ReceiverArg>§args: Vec<NamedArg>§return_ty: TokenStream§looks_like_result: bool§docstring: String

Implementations§

source§

impl FnSignature

source

pub(crate) fn new_function( sig: Signature, args: ExportFnArgs, docstring: String ) -> Result<Self>

source

pub(crate) fn new_method( self_ident: Ident, sig: Signature, args: ExportedImplFnArgs, docstring: String ) -> Result<Self>

source

pub(crate) fn new_constructor( self_ident: Ident, sig: Signature, args: ExportedImplFnArgs, docstring: String ) -> Result<Self>

source

pub(crate) fn new_trait_method( self_ident: Ident, sig: Signature, args: ExportedImplFnArgs, index: u32, docstring: String ) -> Result<Self>

source

pub(crate) fn new( kind: FnKind, sig: Signature, name: Option<String>, defaults: DefaultMap, docstring: String ) -> Result<Self>

source

pub fn lower_return_impl(&self) -> TokenStream

source

pub fn lift_return_impl(&self) -> TokenStream

source

pub fn lift_closure(&self, self_lift: Option<TokenStream>) -> TokenStream

Generate a closure that tries to lift all arguments into a tuple.

The closure moves all scaffolding arguments into itself and returns:

  • The lifted argument tuple on success
  • The field name and error on failure (Err(&'static str, anyhow::Error>)
source

pub fn rust_call_params(&self, self_lift: bool) -> TokenStream

Call a Rust function from a Self::lift_closure success.

This takes an Ok value returned by lift_closure with the name uniffi_args and generates a series of parameters to pass to the Rust function.

source

pub fn params(&self) -> impl Iterator<Item = TokenStream> + '_

Parameters expressions for each of our arguments

source

pub fn scaffolding_fn_ident(&self) -> Result<Ident>

Name of the scaffolding function to generate for this function

source

pub fn scaffolding_param_names(&self) -> impl Iterator<Item = TokenStream> + '_

Scaffolding parameters expressions for each of our arguments

source

pub fn scaffolding_param_types(&self) -> impl Iterator<Item = TokenStream> + '_

source

pub(crate) fn metadata_expr(&self) -> Result<TokenStream>

Generate metadata items for this function

source

pub(crate) fn metadata_items(&self) -> Result<TokenStream>

source

pub(crate) fn metadata_items_for_callback_interface( &self ) -> Result<TokenStream>

Generate metadata items for callback interfaces

Unfortunately, most of this is duplicate code from Self::metadata_items and Self::metadata_expr. However, one issue with that code is that it needs to assume if the arguments are being lifted vs lowered in order to get TYPE_ID_META. That code uses <Type as Lift>::TYPE_ID_META for arguments and <Type as LowerReturn>::TYPE_ID_META for return types, which works for accidental/historical reasons.

The one exception is callback interfaces (#1947), which are handled by this method.

TODO: fix the metadata system so that this is not needed.

source

pub(crate) fn checksum_symbol_name(&self) -> String

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.