Struct uniffi_bindgen::interface::ComponentInterface[][src]

pub struct ComponentInterface { /* fields omitted */ }

The main public interface for this module, representing the complete details of an interface exposed by a rust component and the details of consuming it via an extern-C FFI layer.

Implementations

impl<'ci> ComponentInterface[src]

pub fn from_webidl(idl: &str) -> Result<Self>[src]

Parse a ComponentInterface from a string containing a WebIDL definition.

pub fn namespace(&self) -> &str[src]

The string namespace within which this API should be presented to the caller.

This string would typically be used to prefix function names in the FFI, to build a package or module name for the foreign language, etc.

pub fn iter_enum_definitions(&self) -> Vec<Enum>[src]

List the definitions for every Enum type in the interface.

pub fn get_enum_definition(&self, name: &str) -> Option<&Enum>[src]

Get an Enum definition by name, or None if no such Enum is defined.

pub fn iter_record_definitions(&self) -> Vec<Record>[src]

List the definitions for every Record type in the interface.

pub fn get_record_definition(&self, name: &str) -> Option<&Record>[src]

Get a Record definition by name, or None if no such Record is defined.

pub fn iter_function_definitions(&self) -> Vec<Function>[src]

List the definitions for every Function in the interface.

pub fn get_function_definition(&self, name: &str) -> Option<&Function>[src]

Get a Function definition by name, or None if no such Function is defined.

pub fn iter_object_definitions(&self) -> Vec<Object>[src]

List the definitions for every Object type in the interface.

pub fn get_object_definition(&self, name: &str) -> Option<&Object>[src]

Get an Object definition by name, or None if no such Object is defined.

pub fn iter_callback_interface_definitions(&self) -> Vec<CallbackInterface>[src]

List the definitions for every Callback Interface type in the interface.

pub fn get_callback_interface_definition(
    &self,
    name: &str
) -> Option<&CallbackInterface>
[src]

Get a Callback interface definition by name, or None if no such interface is defined.

pub fn iter_error_definitions(&self) -> Vec<Error>[src]

List the definitions for every Error type in the interface.

pub fn get_error_definition(&self, name: &str) -> Option<&Error>[src]

Get an Error definition by name, or None if no such Error is defined.

pub fn iter_types(&self) -> Vec<Type>[src]

pub fn checksum(&self) -> u64[src]

Calculate a numeric checksum for this ComponentInterface.

The checksum can be used to guard against accidentally using foreign-language bindings generated from one version of an interface with the compiled Rust code from a different version of that interface. It offers the following properties:

  • Two ComponentIntefaces generated from the same WebIDL file, using the same version of uniffi and the same version of Rust, will always have the same checksum value.
  • Two ComponentInterfaces will, with high probability, have different checksum values if: - They were generated from two different WebIDL files. - They were generated by two different versions of uniffi

The checksum may or may not change depending on the version of Rust used; since we expect consumers to be using the same executable to generate both the scaffolding and the bindings, assuming the same version of Rust seems acceptable.

Note that this is designed to prevent accidents, not attacks, so there is no need for the checksum to be cryptographically secure.

TODO: it’s not clear to me if the derivation of Hash is actually deterministic enough to ensure the guarantees above, or if it might be sensitive to e.g. compiler-driven re-ordering of struct field. Let’s see how it goes…

pub fn ffi_namespace(&self) -> String[src]

The namespace to use in FFI-level function definitions.

The value returned by this method is used as a prefix to namespace all FFI-level functions used in this ComponentInterface.

Since these names are an internal implementation detail that is not typically visible to consumers, we take the opportunity to add an additional safety guard by including a 4-hex-char checksum in each name. If foreign-language bindings attempt to load and use a version of the Rust code compiled from a different UDL definition than the one used for the bindings themselves, then there is a high probability of checksum mismatch and they will fail to link against the compiled Rust code. The result will be an ugly inscrutable link-time error, but that is a lot better than triggering potentially arbitrary memory unsafety!

pub fn ffi_rustbuffer_alloc(&self) -> FFIFunction[src]

Builtin FFI function for allocating a new RustBuffer. This is needed so that the foreign language bindings can create buffers in which to pass complex data types across the FFI.

pub fn ffi_rustbuffer_from_bytes(&self) -> FFIFunction[src]

Builtin FFI function for copying foreign-owned bytes This is needed so that the foreign language bindings can create buffers in which to pass complex data types across the FFI.

pub fn ffi_rustbuffer_free(&self) -> FFIFunction[src]

Builtin FFI function for freeing a RustBuffer. This is needed so that the foreign language bindings can free buffers in which they received complex data types returned across the FFI.

pub fn ffi_rustbuffer_reserve(&self) -> FFIFunction[src]

Builtin FFI function for reserving extra space in a RustBuffer. This is needed so that the foreign language bindings can grow buffers used for passing complex data types across the FFI.

pub fn ffi_string_free(&self) -> FFIFunction[src]

Builtin FFI function for freeing a string. This is needed for foreign-language code when dealing with errors, so that it can free the error message string. TODO: make our error class return the message in a RustBuffer so we can free it using the exisiting bytebuffer-freeing function rather than a special one.

pub fn iter_ffi_function_definitions(&self) -> Vec<FFIFunction>[src]

List the definitions of all FFI functions in the interface.

The set of FFI functions is derived automatically from the set of higher-level types along with the builtin FFI helper functions.

Trait Implementations

impl Debug for ComponentInterface[src]

impl Default for ComponentInterface[src]

impl From<&'_ ComponentInterface> for Config[src]

impl From<&'_ ComponentInterface> for Config[src]

impl From<&'_ ComponentInterface> for Config[src]

impl From<&'_ ComponentInterface> for Config[src]

impl From<&'_ ComponentInterface> for Config[src]

impl FromStr for ComponentInterface[src]

Convenience implementation for parsing a ComponentInterface from a string.

type Err = Error

The associated error which can be returned from parsing.

impl Hash for ComponentInterface[src]

ComponentInterface structs can be hashed, but this is mostly a convenient way to produce a checksum of their contents. They’re not really intended to live in a hashtable.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.