Trait Rpc

Source
pub trait Rpc: Serialize + DeserializeOwned {
    type Request: Serialize + DeserializeOwned + From<Self>;
    type Response: Serialize + DeserializeOwned;

    // Required method
    async fn handle(self) -> Result<Self::Response>;

    // Provided methods
    async fn exec(self, peer: &Peer) -> Result<Self::Response> { ... }
    async fn remote(self) -> Result<Body> { ... }
}

Required Associated Types§

Required Methods§

Source

async fn handle(self) -> Result<Self::Response>

Implements the RPC on this node, automatically wrapped by the trait on remotes.

Provided Methods§

Source

async fn exec(self, peer: &Peer) -> Result<Self::Response>

Source

async fn remote(self) -> Result<Body>

Wraps the locally produced value into an HTTP Body. Can be overridden to provide a faster path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§