Struct ProtocolContext

Source
pub struct ProtocolContext {
    pub proto_id: ProtocolId,
    /* private fields */
}
Expand description

Protocol handle context

Fields§

§proto_id: ProtocolId

Protocol id

Methods from Deref<Target = ServiceContext>§

Source

pub async fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>

Create a new listener

Source

pub async fn dial( &self, address: Multiaddr, target: TargetProtocol, ) -> Result<(), SendErrorKind>

Initiate a connection request to address

Source

pub async fn disconnect( &self, session_id: SessionId, ) -> Result<(), SendErrorKind>

Disconnect a connection

Source

pub async fn send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>

Send message

Source

pub async fn quick_send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>

Send message on quick channel

Source

pub async fn filter_broadcast( &self, session_ids: TargetSession, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>

Send data to the specified protocol for the specified sessions.

Source

pub async fn quick_filter_broadcast( &self, session_ids: TargetSession, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>

Send data to the specified protocol for the specified sessions on quick channel.

Source

pub async fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind>
where T: Future<Output = ()> + 'static + Send,

Send a future task

Source

pub async fn open_protocol( &self, session_id: SessionId, proto_id: ProtocolId, ) -> Result<(), SendErrorKind>

Try open a protocol

If the protocol has been open, do nothing

Source

pub async fn open_protocols( &self, session_id: SessionId, target: TargetProtocol, ) -> Result<(), SendErrorKind>

Try open protocol

If the protocol has been open, do nothing

Source

pub async fn close_protocol( &self, session_id: SessionId, proto_id: ProtocolId, ) -> Result<(), SendErrorKind>

Try close a protocol

If the protocol has been closed, do nothing

Source

pub fn control(&self) -> &ServiceAsyncControl

Get the internal channel sender side handle

Source

pub fn listens(&self) -> &[Multiaddr]

Get service listen address list

Source

pub async fn set_service_notify( &self, proto_id: ProtocolId, interval: Duration, token: u64, ) -> Result<(), SendErrorKind>

Set a service notify token

Source

pub async fn set_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, interval: Duration, token: u64, ) -> Result<(), SendErrorKind>

Set a session notify token

Source

pub async fn remove_service_notify( &self, proto_id: ProtocolId, token: u64, ) -> Result<(), SendErrorKind>

Remove a service timer by a token

Source

pub async fn remove_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, token: u64, ) -> Result<(), SendErrorKind>

Remove a session timer by a token

Source

pub async fn close(&self) -> Result<(), SendErrorKind>

Close service.

Order:

  1. close all listens
  2. try close all session’s protocol stream
  3. try close all session
  4. close service
Source

pub async fn shutdown(&self) -> Result<(), SendErrorKind>

Shutdown service, don’t care anything, may cause partial message loss

Trait Implementations§

Source§

impl Deref for ProtocolContext

Source§

type Target = ServiceContext

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for ProtocolContext

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,