Struct tentacle::builder::MetaBuilder[][src]

pub struct MetaBuilder { /* fields omitted */ }

Builder for protocol meta

Implementations

impl MetaBuilder[src]

pub fn new() -> Self[src]

New a default builder

pub fn id(self, id: ProtocolId) -> Self[src]

Define protocol id

It is just an internal index of the system that identifies the open/close and message transfer for the specified protocol.

pub fn name<T: Fn(ProtocolId) -> String + 'static + Send + Sync>(
    self,
    name: T
) -> Self
[src]

Define protocol name, default is "/p2p/protocol_id"

Used to interact with the remote service to determine whether the protocol is supported.

If not found, the protocol connection(not session just sub stream) will be closed, and return a ProtocolSelectError event.

pub fn support_versions(self, versions: Vec<String>) -> Self[src]

Define protocol support versions, default is vec!["0.0.1".to_owned()]

Used to interact with the remote service to confirm that both parties open the same version of the protocol.

If not found, the protocol connection(not session just sub stream) will be closed, and return a ProtocolSelectError event.

pub fn codec<T: Fn() -> Box<dyn Codec + Send + 'static> + 'static + Send + Sync>(
    self,
    codec: T
) -> Self
[src]

Define protocol codec, default is LengthDelimitedCodec

pub fn service_handle<T: FnOnce() -> ProtocolHandle<Box<dyn ServiceProtocol + Send + Unpin + 'static>>>(
    self,
    service_handle: T
) -> Self
[src]

Define protocol service handle, default is neither

pub fn session_handle<T: FnMut() -> ProtocolHandle<Box<dyn SessionProtocol + Send + Unpin + 'static>> + Send + 'static>(
    self,
    session_handle: T
) -> Self
[src]

Define protocol session handle, default is neither

pub fn protocol_spawn<T: ProtocolSpawn + Send + Sync + 'static>(
    self,
    spawn: T
) -> Self
[src]

Define the spawn process of the protocol read part

Mutually exclusive with protocol handle

pub fn select_version<T>(self, f: T) -> Self where
    T: Fn() -> Option<SelectFn<String>> + Send + Sync + 'static, 
[src]

Protocol version selection rule, default is select_version

pub fn before_send<T>(self, f: T) -> Self where
    T: Fn(Bytes) -> Bytes + 'static + Send
[src]

Unified processing of messages before they are sent

pub fn before_receive<T>(self, f: T) -> Self where
    T: Fn() -> Option<Box<dyn Fn(BytesMut) -> Result<Bytes, Error> + Send + 'static>> + Send + Sync + 'static, 
[src]

Unified processing of messages before user received

pub fn flag(self, flag: BlockingFlag) -> Self[src]

Set a flag to control function behavior

pub fn build(self) -> ProtocolMeta[src]

Combine the configuration of this builder to create a ProtocolMeta

Trait Implementations

impl Default for MetaBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,