[−][src]Struct potatonet_node::NodeContext
节点上下文
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]
&'_ self,
topic: &'_ str,
__arg2: F
) -> SubscribeId where
T: Topic,
F: FnMut(&NodeContext, T) -> R + Send + 'static,
R: Future<Output = ()> + Send + 'static,
订阅指定主题的消息
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]
T: Topic,
F: FnMut(&NodeContext, T) -> R + Send + 'static,
R: Future<Output = ()> + Send + 'static,
订阅消息 如果重复订阅,则会按订阅顺序依次触发回调函数,并不会增加数据传输流量
pub async fn unsubscribe<'_>(&'_ self, id: SubscribeId)
[src]
取消订阅
Trait Implementations
impl<'a> Context for NodeContext<'a>
[src]
fn call<'life0, 'life1, 'async_trait, T, R>(
&'life0 self,
service_name: &'life1 str,
request: Request<T>
) -> Pin<Box<dyn Future<Output = Result<Response<R>>> + Send + 'async_trait>> where
T: Serialize + Send + 'static,
R: DeserializeOwned + Send + 'static,
T: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
service_name: &'life1 str,
request: Request<T>
) -> Pin<Box<dyn Future<Output = Result<Response<R>>> + Send + 'async_trait>> where
T: Serialize + Send + 'static,
R: DeserializeOwned + Send + 'static,
T: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn notify<'life0, 'life1, 'async_trait, T: Serialize + Send + 'static>(
&'life0 self,
service_name: &'life1 str,
request: Request<T>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
service_name: &'life1 str,
request: Request<T>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn notify_to<'life0, 'async_trait, T: Serialize + Send + 'static>(
&'life0 self,
to: ServiceId,
request: Request<T>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
to: ServiceId,
request: Request<T>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn publish_with_topic<'life0, 'life1, 'async_trait, T: Topic>(
&'life0 self,
topic: &'life1 str,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
topic: &'life1 str,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn publish<'life0, 'async_trait, T>(
&'life0 self,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
T: Topic + 'async_trait,
[src]
&'life0 self,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
T: Topic + 'async_trait,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,