Struct tentacle::context::ProtocolContextMutRef
source · [−]pub struct ProtocolContextMutRef<'a> {
pub session: &'a SessionContext,
/* private fields */
}
Expand description
Protocol handle context with session context
Use in the callback method with a clear source of the event means tentacle know the event product from which session
Fields
session: &'a SessionContext
Session context
Implementations
sourceimpl<'a> ProtocolContextMutRef<'a>
impl<'a> ProtocolContextMutRef<'a>
sourcepub async fn send_message(&self, data: Bytes) -> Result<(), SendErrorKind>
pub async fn send_message(&self, data: Bytes) -> Result<(), SendErrorKind>
Send message to current protocol current session
sourcepub async fn quick_send_message(&self, data: Bytes) -> Result<(), SendErrorKind>
pub async fn quick_send_message(&self, data: Bytes) -> Result<(), SendErrorKind>
Send message to current protocol current session on quick channel
sourcepub fn proto_id(&self) -> ProtocolId
pub fn proto_id(&self) -> ProtocolId
Protocol id
Methods from Deref<Target = ServiceContext>
sourcepub async fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
pub async fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
Create a new listener
sourcepub async fn dial(
&self,
address: Multiaddr,
target: TargetProtocol
) -> Result<(), SendErrorKind>
pub async fn dial(
&self,
address: Multiaddr,
target: TargetProtocol
) -> Result<(), SendErrorKind>
Initiate a connection request to address
sourcepub async fn disconnect(
&self,
session_id: SessionId
) -> Result<(), SendErrorKind>
pub async fn disconnect(
&self,
session_id: SessionId
) -> Result<(), SendErrorKind>
Disconnect a connection
sourcepub async fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub async fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send message
sourcepub async fn quick_send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub async fn quick_send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send message on quick channel
sourcepub async fn filter_broadcast(
&self,
session_ids: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
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.
sourcepub async fn quick_filter_broadcast(
&self,
session_ids: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
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.
sourcepub async fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind> where
T: Future<Output = ()> + 'static + Send,
pub async fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind> where
T: Future<Output = ()> + 'static + Send,
Send a future task
sourcepub async fn open_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
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
sourcepub async fn open_protocols(
&self,
session_id: SessionId,
target: TargetProtocol
) -> Result<(), SendErrorKind>
pub async fn open_protocols(
&self,
session_id: SessionId,
target: TargetProtocol
) -> Result<(), SendErrorKind>
Try open protocol
If the protocol has been open, do nothing
sourcepub async fn close_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
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
sourcepub fn control(&self) -> &ServiceAsyncControl
pub fn control(&self) -> &ServiceAsyncControl
Get the internal channel sender side handle
sourcepub fn protocols(&self) -> &Arc<HashMap<ProtocolId, ProtocolInfo>>
pub fn protocols(&self) -> &Arc<HashMap<ProtocolId, ProtocolInfo>>
Get service protocol message, Map(ID, Name), but can’t modify
sourcepub fn key_pair(&self) -> Option<&SecioKeyPair>
pub fn key_pair(&self) -> Option<&SecioKeyPair>
Get the key pair of self
sourcepub async fn set_service_notify(
&self,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
pub async fn set_service_notify(
&self,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
Set a service notify token
sourcepub async fn set_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
pub async fn set_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
Set a session notify token
sourcepub async fn remove_service_notify(
&self,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
pub async fn remove_service_notify(
&self,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
Remove a service timer by a token
sourcepub async fn remove_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
pub async fn remove_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
Remove a session timer by a token
sourcepub async fn close(&self) -> Result<(), SendErrorKind>
pub async fn close(&self) -> Result<(), SendErrorKind>
Close service.
Order:
- close all listens
- try close all session’s protocol stream
- try close all session
- close service
sourcepub async fn shutdown(&self) -> Result<(), SendErrorKind>
pub async fn shutdown(&self) -> Result<(), SendErrorKind>
Shutdown service, don’t care anything, may cause partial message loss
Trait Implementations
sourceimpl<'a> Deref for ProtocolContextMutRef<'a>
impl<'a> Deref for ProtocolContextMutRef<'a>
type Target = ProtocolContext
type Target = ProtocolContext
The resulting type after dereferencing.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ProtocolContextMutRef<'a>
impl<'a> Send for ProtocolContextMutRef<'a>
impl<'a> Sync for ProtocolContextMutRef<'a>
impl<'a> Unpin for ProtocolContextMutRef<'a>
impl<'a> !UnwindSafe for ProtocolContextMutRef<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more