AbiProtocol

Enum AbiProtocol 

Source
#[repr(C, u8)]
pub enum AbiProtocol { RegularCall { trait_object: TraitObject, compatibility_mask: u64, data: *const u8, data_length: usize, abi_result: *mut (), receiver: unsafe extern "C" fn(outcome: *const RawAbiCallResult, result_receiver: *mut ()), effective_version: u32, method_number: u16, }, InterrogateVersion { schema_version_receiver: *mut u16, abi_version_receiver: *mut u32, }, InterrogateMethods { schema_version_required: u16, callee_schema_version_interrogated: u32, result_receiver: *mut (), callback: unsafe extern "C" fn(receiver: *mut (), callee_schema_version: u16, data: *const u8, len: usize), }, CreateInstance { trait_object_receiver: *mut TraitObject, error_receiver: *mut (), error_callback: unsafe extern "C" fn(error_receiver: *mut (), error: *const AbiErrorMsg), }, DropInstance { trait_object: TraitObject, }, }
Expand description

This struct carries all information between different libraries. I.e, it is the sole carrier of information accross an FFI-boundary.

Variants§

§

RegularCall

Call a method on a trait object.

Fields

§trait_object: TraitObject

Type-erased actual trait object. This is the 16 bytes o trait fat pointer.

§compatibility_mask: u64

For every argument, a bit ‘1’ if said argument is a reference that can just be binary copied, as a pointer

§data: *const u8

Data for parameters, possibly serialized

§data_length: usize

Length of parameters-data

§abi_result: *mut ()

Instance of type AbiCallResult<T>, to which the return-value callback will write deserialized results or panic-message.

§receiver: unsafe extern "C" fn(outcome: *const RawAbiCallResult, result_receiver: *mut ())

Callback which will be called by callee in order to supply the return value (without having to allocate heap-memory)

§effective_version: u32

The negotiated protocol version

§method_number: u16

The method to call. This is the method number using the numbering of the callee.

§

InterrogateVersion

Get callee version

Fields

§schema_version_receiver: *mut u16

The version of the callee savefile schema. This can only change if the savefile library is upgraded.

§abi_version_receiver: *mut u32

The version of the data schema, on the callee.

§

InterrogateMethods

Get schema

Fields

§schema_version_required: u16

The version of the schema that the caller expects.

§callee_schema_version_interrogated: u32

The schema version that the caller expects the callee to communicate using. I.e, if callee has a later version of the ‘savefile’ library, this can be used to arrange for it to speak an older dialect. In theory, but savefile is still involving and there is always a risk that ABI-breaks will be necessary.

§result_receiver: *mut ()

A pointer pointing at the location that that caller will expect the return value to be written. Note, callee does not actually write to this, it just calls callback, which allows caller to write to the result_receiver. The field is still needed here, since the callback is a bare function, and cannot capture any data.

§callback: unsafe extern "C" fn(receiver: *mut (), callee_schema_version: u16, data: *const u8, len: usize)

Called by callee to convey information back to caller. receiver is place the caller will want to write the result.

§

CreateInstance

Create a new trait object.

Fields

§trait_object_receiver: *mut TraitObject

Pointer which will receive the fat pointer to the dyn trait object, allocated on heap using Box.

§error_receiver: *mut ()

Opaque pointer to callers representation of error (String)

§error_callback: unsafe extern "C" fn(error_receiver: *mut (), error: *const AbiErrorMsg)

Called by callee if instance creation fails (by panic)

§

DropInstance

Drop a trait object.

Fields

§trait_object: TraitObject

dyn trait fat pointer

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.