PackagedTraitObject

Struct PackagedTraitObject 

Source
#[repr(C)]
pub struct PackagedTraitObject { pub trait_object: TraitObject, pub entry: unsafe extern "C" fn(flag: AbiProtocol), }
Expand description

A trait object together with its entry point

Fields§

§trait_object: TraitObject

Type erased trait object for an ABI-exported trait

§entry: unsafe extern "C" fn(flag: AbiProtocol)

The low level entry point

Implementations§

Source§

impl PackagedTraitObject

Source

pub fn new<T: AbiExportable + ?Sized>(boxed: Box<T>) -> PackagedTraitObject

Create a PackagedTraitObject from a Box<T> . T must be a trait object. T must implement AbiExportable, which means it has an ::ABI_ENTRY associated type that gives the entry point.

Source

pub fn new_from_ptr<T>(r: *const T) -> PackagedTraitObject
where T: AbiExportable + ?Sized,

Create a PackagedTraitObject from a &T. T must be a trait object. T must implement AbiExportable, which means it has an ::ABI_ENTRY associated type that gives the entry point. Note, we use *const T here even for mutable cases, but it doesn’t matter since it’s never dereferenced, it’s just cast to other stuff and then finally back to the right type.

Source

pub fn serialize( self, serializer: &mut Serializer<'_, impl Write>, ) -> Result<(), SavefileError>

‘Serialize’ this object. I.e, write it to a binary buffer, so that we can send it to a foreign library.

Source

pub unsafe fn deserialize( deserializer: &mut Deserializer<'_, impl Read>, ) -> Result<PackagedTraitObject, SavefileError>

‘Deserialize’ this object. I.e, read it from a binary buffer, so that we can receive it from a foreign library.

§Safety

The data available to read from Deserializer must be correct, and contain a valid serialized PackagedTraitObject.

Trait Implementations§

Source§

impl Debug for PackagedTraitObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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, 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.