Trait linera_witty::ExportedFunctionInterface

source ·
pub trait ExportedFunctionInterface {
    type HostParameters: WitType;
    type HostResults: WitStore;
    type GuestInterface: GuestInterface<FlatHostParameters = <<Self::HostParameters as WitType>::Layout as Layout>::Flat, ResultStorage = Self::ResultStorage>;
    type GuestParameters;
    type GuestResults;
    type ResultStorage: ResultStorage<OutputFor<Self::HostResults> = Self::GuestResults>;

    // Required methods
    fn lift_parameters<Instance>(
        guest_parameters: Self::GuestParameters,
        memory: &Memory<'_, Instance>,
    ) -> Result<(Self::HostParameters, Self::ResultStorage), RuntimeError>
       where Instance: InstanceWithMemory,
             <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>;
    fn lower_results<Instance>(
        results: Self::HostResults,
        result_storage: Self::ResultStorage,
        memory: &mut Memory<'_, Instance>,
    ) -> Result<Self::GuestResults, RuntimeError>
       where Instance: InstanceWithMemory,
             <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>;
}
Expand description

Representation of an exported host function’s interface.

Implemented for a tuple pair of the host parameters type and the host results type, and allows converting to the signature the guest Wasm instance uses for that host function.

Required Associated Types§

source

type HostParameters: WitType

The type representing the host-side parameters.

source

type HostResults: WitStore

The type representing the host-side results.

source

type GuestInterface: GuestInterface<FlatHostParameters = <<Self::HostParameters as WitType>::Layout as Layout>::Flat, ResultStorage = Self::ResultStorage>

The representation of the guest-side function interface.

source

type GuestParameters

The type representing the guest-side parameters.

source

type GuestResults

The type representing the guest-side results.

source

type ResultStorage: ResultStorage<OutputFor<Self::HostResults> = Self::GuestResults>

How the results from the exported host function should be sent back to the guest.

Required Methods§

source

fn lift_parameters<Instance>( guest_parameters: Self::GuestParameters, memory: &Memory<'_, Instance>, ) -> Result<(Self::HostParameters, Self::ResultStorage), RuntimeError>
where Instance: InstanceWithMemory, <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,

Converts the guest-side parameters into the host-side parameters.

source

fn lower_results<Instance>( results: Self::HostResults, result_storage: Self::ResultStorage, memory: &mut Memory<'_, Instance>, ) -> Result<Self::GuestResults, RuntimeError>
where Instance: InstanceWithMemory, <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,

Converts the host-side results into the guest-side results.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<Parameters, Results> ExportedFunctionInterface for (Parameters, Results)
where Parameters: WitLoad, Results: WitStore, (<Parameters::Layout as Layout>::Flat, <Results::Layout as Layout>::Flat): GuestInterface<FlatHostParameters = <Parameters::Layout as Layout>::Flat>, <() as WitType>::Layout: Layout<Flat = HNil>,

§

type HostParameters = Parameters

§

type HostResults = Results

§

type GuestInterface = (<<Parameters as WitType>::Layout as Layout>::Flat, <<Results as WitType>::Layout as Layout>::Flat)

§

type GuestParameters = <<(Parameters, Results) as ExportedFunctionInterface>::GuestInterface as GuestInterface>::FlatGuestParameters

§

type GuestResults = <<<(Parameters, Results) as ExportedFunctionInterface>::GuestInterface as GuestInterface>::ResultStorage as ResultStorage>::OutputFor<<(Parameters, Results) as ExportedFunctionInterface>::HostResults>

§

type ResultStorage = <<(Parameters, Results) as ExportedFunctionInterface>::GuestInterface as GuestInterface>::ResultStorage

source§

fn lift_parameters<Instance>( guest_parameters: Self::GuestParameters, memory: &Memory<'_, Instance>, ) -> Result<(Self::HostParameters, Self::ResultStorage), RuntimeError>
where Instance: InstanceWithMemory, <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,

source§

fn lower_results<Instance>( results: Self::HostResults, result_storage: Self::ResultStorage, memory: &mut Memory<'_, Instance>, ) -> Result<Self::GuestResults, RuntimeError>
where Instance: InstanceWithMemory, <Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,

Implementors§