Cast

Trait Cast 

Source
pub trait Cast:
    Sized
    + Sync
    + Send
    + 'static {
    type Notification: Send + 'static;
    type Encoder: Encode<Item = Self::Notification> + Send + 'static;
    type Decoder: Decode<Item = Self::Notification> + Send + 'static;

    const ID: ProcedureId;
    const NAME: &'static str;

    // Provided methods
    fn enable_async(notification: &Self::Notification) -> bool { ... }
    fn client(service: &ClientServiceHandle) -> CastClient<'_, Self>
       where Self::Encoder: Default { ... }
    fn client_with_encoder(
        service: &ClientServiceHandle,
        encoder: Self::Encoder,
    ) -> CastClient<'_, Self> { ... }
}
Expand description

Notification RPC.

Required Associated Constants§

Source

const ID: ProcedureId

The identifier of the procedure.

Source

const NAME: &'static str

The name of the procedure.

This is only used for debugging purpose.

Required Associated Types§

Source

type Notification: Send + 'static

Notification message.

Source

type Encoder: Encode<Item = Self::Notification> + Send + 'static

Notification message encoder.

Source

type Decoder: Decode<Item = Self::Notification> + Send + 'static

Notification message decoder.

Provided Methods§

Source

fn enable_async(notification: &Self::Notification) -> bool

If it returns true, encoding/decoding notification messages will be executed asynchronously.

For large RPC messages, asynchronous encoding/decoding may improve real-time property (especially if messages will be encoded/decoded by using serde).

The default implementation always return false.

Source

fn client(service: &ClientServiceHandle) -> CastClient<'_, Self>
where Self::Encoder: Default,

Makes a new RPC client.

Source

fn client_with_encoder( service: &ClientServiceHandle, encoder: Self::Encoder, ) -> CastClient<'_, Self>

Makes a new RPC client with the given encoder maker.

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§