Trait ToFFI

Source
pub(crate) trait ToFFI {
    type Str<'a>: AsRawFFI + 'a
       where Self: 'a;

    // Required method
    fn ffi<'a>(&'a self) -> Self::Str<'a>;
}
Expand description

Trait for types that can be converted to FFI string representation.

This trait enables conversion of Rust types into string representations suitable for passing to C functions via FFI. The string type is parameterized to allow for both borrowed and owned string representations depending on the source data.

Required Associated Types§

Source

type Str<'a>: AsRawFFI + 'a where Self: 'a

The string type returned by the FFI conversion.

This can be &str for types that already contain string data, or String for types that need to generate string representations (like hex encoding of byte arrays).

Required Methods§

Source

fn ffi<'a>(&'a self) -> Self::Str<'a>

Converts this value to its FFI string representation.

The returned string type implements AsRawFFI and can be safely passed across the FFI boundary.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToFFI for [u8; 32]

Source§

type Str<'a> = Buffer<32>

Source§

fn ffi<'a>(&'a self) -> Self::Str<'a>

Source§

impl ToFFI for [u8; 64]

Source§

type Str<'a> = Buffer<64>

Source§

fn ffi<'a>(&'a self) -> Self::Str<'a>

Source§

impl ToFFI for [u8]

Source§

type Str<'a> = String

Source§

fn ffi<'a>(&'a self) -> Self::Str<'a>

Source§

impl<T: ToFFI> ToFFI for Option<&T>
where for<'a> Option<T::Str<'a>>: AsRawFFI<FFI = ConstStr>,

Source§

type Str<'a> = Option<<T as ToFFI>::Str<'a>> where Self: 'a

Source§

fn ffi<'a>(&'a self) -> Self::Str<'a>

Implementors§

Source§

impl ToFFI for Bip340Tweak

Source§

type Str<'a> = Buffer<32>

Source§

impl ToFFI for MessageHash

Source§

type Str<'a> = Buffer<32>

Source§

impl ToFFI for KeygenId

Source§

type Str<'a> = &'a str

Source§

impl ToFFI for KeygenPrivateKey

Source§

type Str<'a> = Buffer<32>

Source§

impl ToFFI for RoomUUID

Source§

type Str<'a> = &'a str

Source§

impl<T: 'static> ToFFI for ExtendedPrivateKey<T>

Source§

type Str<'a> = &'a str

Source§

impl<T: 'static> ToFFI for ExtendedPublicKey<T>

Source§

type Str<'a> = &'a str

Source§

impl<T: 'static> ToFFI for SecretShare<T>

Source§

type Str<'a> = &'a str