Skip to main content

ChannelContract

Trait ChannelContract 

Source
pub trait ChannelContract:
    Clone
    + Send
    + Sync
    + 'static {
    type Input: Send + 'static;
    type Output: Send + 'static;
    type StatusResponse: Send + 'static;
    type CancelResponse: Send + 'static;

    const TRANSPORT: Transport;
    const ID: &'static str = "";
    const MODE: &'static str = "rpc";
    const SERVICE: &'static str = "";
    const METHOD: &'static str = "";
    const IDL: &'static str = "";

    // Required method
    fn invoke(
        channel: Channel<Self>,
        request: Self::Input,
    ) -> impl Future<Output = Result<Self::Output>> + Send;

    // Provided methods
    fn matches_contract(contract: &ContractDescriptor) -> bool { ... }
    fn validate_companion(
        _contract: &ContractDescriptor,
        _status: bool,
    ) -> Result<()> { ... }
    fn validate_input(_request: &Self::Input) -> Result<()> { ... }
    fn execution(_response: &Self::Output) -> Result<(bool, String)> { ... }
    fn status(
        _channel: Channel<Self>,
    ) -> impl Future<Output = Result<Self::StatusResponse>> + Send { ... }
    fn cancel(
        _channel: Channel<Self>,
    ) -> impl Future<Output = Result<Self::CancelResponse>> + Send { ... }
    fn status_state(_response: &Self::StatusResponse) -> Result<&str> { ... }
}
Expand description

Compile-time message types and communication for one capability contract.

Required Associated Constants§

Provided Associated Constants§

Source

const ID: &'static str = ""

Contract ID fixed by the binding; empty when selected at connection time.

Source

const MODE: &'static str = "rpc"

Source

const SERVICE: &'static str = ""

Source

const METHOD: &'static str = ""

Source

const IDL: &'static str = ""

Required Associated Types§

Source

type Input: Send + 'static

Source

type Output: Send + 'static

Source

type StatusResponse: Send + 'static

Source

type CancelResponse: Send + 'static

Required Methods§

Source

fn invoke( channel: Channel<Self>, request: Self::Input, ) -> impl Future<Output = Result<Self::Output>> + Send

Provided Methods§

Source

fn matches_contract(contract: &ContractDescriptor) -> bool

Source

fn validate_companion( _contract: &ContractDescriptor, _status: bool, ) -> Result<()>

Source

fn validate_input(_request: &Self::Input) -> Result<()>

Source

fn execution(_response: &Self::Output) -> Result<(bool, String)>

Source

fn status( _channel: Channel<Self>, ) -> impl Future<Output = Result<Self::StatusResponse>> + Send

Source

fn cancel( _channel: Channel<Self>, ) -> impl Future<Output = Result<Self::CancelResponse>> + Send

Source

fn status_state(_response: &Self::StatusResponse) -> Result<&str>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

浙ICP备2023005800号-2 浙公网安备33010902005384号