pub trait InterfaceType: Sized {
Show 21 associated items type Send; type Sync; type Clone; type Default; type Display; type Debug; type Serialize; type Eq; type PartialEq; type Ord; type PartialOrd; type Hash; type Deserialize; type Iterator; type DoubleEndedIterator; type FmtWrite; type IoWrite; type IoSeek; type IoRead; type IoBufRead; type Error;
}
Expand description

Defines the usable/required traits when creating a DynTrait<Pointer<()>, ThisInterfaceType>.

This trait can only be implemented using the #[derive(StableAbi)] derive with the #[sabi(impl_InterfaceType(...))] helper attribute, giving a default value to each associated type, so that adding associated types is not a breaking change.

The value of every associated type can be.

  • Implemented<_>: the trait would be required by, and be usable in DynTrait.

  • Unimplemented<_>: the trait would not be required by, and not be usable in DynTrait.

Example


use abi_stable::{erased_types::InterfaceType, type_level::bools::*, StableAbi};

#[repr(C)]
#[derive(StableAbi)]
#[sabi(impl_InterfaceType(Clone, Debug))]
pub struct FooInterface;

/*
The `#[sabi(impl_InterfaceType(Clone, Debug))]` helper attribute
(as part of #[derive(StableAbi)]) above is roughly equivalent to this impl:

impl InterfaceType for FooInterface {
    type Clone = Implemented<trait_marker::Clone>;

    type Debug = Implemented<trait_marker::Debug>;

    /////////////////////////////////////
    //// defaulted associated types
    /////////////////////////////////////

    // Changing this to require/unrequire in minor versions, is an abi breaking change.
    // type Send = Unimplemented<trait_marker::Send>;

    // Changing this to require/unrequire in minor versions, is an abi breaking change.
    // type Sync = Unimplemented<trait_marker::Sync>;

    // type Iterator = Unimplemented<trait_marker::Iterator>;

    // type DoubleEndedIterator = Unimplemented<trait_marker::DoubleEndedIterator>;

    // type Default = Unimplemented<trait_marker::Default>;

    // type Display = Unimplemented<trait_marker::Display>;

    // type Serialize = Unimplemented<trait_marker::Serialize>;

    // type Eq = Unimplemented<trait_marker::Eq>;

    // type PartialEq = Unimplemented<trait_marker::PartialEq>;

    // type Ord = Unimplemented<trait_marker::Ord>;

    // type PartialOrd = Unimplemented<trait_marker::PartialOrd>;

    // type Hash = Unimplemented<trait_marker::Hash>;

    // type Deserialize = Unimplemented<trait_marker::Deserialize>;

    // type FmtWrite = Unimplemented<trait_marker::FmtWrite>;

    // type IoWrite = Unimplemented<trait_marker::IoWrite>;

    // type IoSeek = Unimplemented<trait_marker::IoSeek>;

    // type IoRead = Unimplemented<trait_marker::IoRead>;

    // type IoBufRead = Unimplemented<trait_marker::IoBufRead>;

    // type Error = Unimplemented<trait_marker::Error>;
}
*/


Associated Types

Changing this to require/unrequire in minor versions, is an abi breaking change.

Changing this to require/unrequire in minor versions, is an abi breaking change.

Implementations on Foreign Types

Implementors