[][src]Struct potatonet_node::NodeContext

pub struct NodeContext<'a> { /* fields omitted */ }

节点上下文

Methods

impl<'a> NodeContext<'a>[src]

pub fn from(&self) -> Option<ServiceId>[src]

请求或者通知来源服务id

pub fn service_name(&self) -> &str[src]

当前服务名称

pub fn service_id(&self) -> ServiceId[src]

当前服务id

pub fn shutdown_node(&self)[src]

停止节点运行

impl<'a> NodeContext<'a>[src]

pub async fn subscribe_with_topic<'_, '_, T, F, R>(
    &'_ self,
    topic: &'_ str,
    __arg2: F
) -> SubscribeId where
    T: Topic,
    F: FnMut(&NodeContext, T) -> R + Send + 'static,
    R: Future<Output = ()> + Send + 'static, 
[src]

订阅指定主题的消息

pub async fn subscribe<'_, T, F, R>(&'_ self, handler: F) -> SubscribeId where
    T: Topic,
    F: FnMut(&NodeContext, T) -> R + Send + 'static,
    R: Future<Output = ()> + Send + 'static, 
[src]

订阅消息 如果重复订阅,则会按订阅顺序依次触发回调函数,并不会增加数据传输流量

pub async fn unsubscribe<'_>(&'_ self, id: SubscribeId)[src]

取消订阅

Trait Implementations

impl<'a> Context for NodeContext<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for NodeContext<'a>

impl<'a> Send for NodeContext<'a>

impl<'a> Sync for NodeContext<'a>

impl<'a> Unpin for NodeContext<'a>

impl<'a> !UnwindSafe for NodeContext<'a>

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, 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.