pub struct ChannelManager { /* private fields */ }Available on crate feature
channels only.Expand description
Manage startup, shutdown, and querying of multiple IM channels.
Supports:
- Registering multiple ChannelPlugins (QQ Bot, Feishu, etc.)
- Unified start / stop
- Query or send by ID
- Auto-stop all channels on Drop
Implementations§
Source§impl ChannelManager
impl ChannelManager
pub fn new() -> ChannelManager
Sourcepub fn register(&mut self, plugin: Box<dyn ChannelPlugin>)
pub fn register(&mut self, plugin: Box<dyn ChannelPlugin>)
Register a channel plugin
pub fn is_empty(&self) -> bool
Sourcepub async fn start_all(
&mut self,
handler_factory: impl Fn(&str) -> Arc<dyn MessageHandler> + Sync,
) -> Vec<Result<(), ReactError>>
pub async fn start_all( &mut self, handler_factory: impl Fn(&str) -> Arc<dyn MessageHandler> + Sync, ) -> Vec<Result<(), ReactError>>
Start all registered channels.
Creates a task for each channel and starts them concurrently. Returns Vec<Result<()>>
so the caller can inspect the result of each channel; a single failure does not affect others.
Sourcepub async fn stop_all(&mut self) -> Result<(), ReactError>
pub async fn stop_all(&mut self) -> Result<(), ReactError>
Stop all registered channels
Sourcepub fn get(&self, id: &str) -> Option<&dyn ChannelPlugin>
pub fn get(&self, id: &str) -> Option<&dyn ChannelPlugin>
Get a channel reference by ID
Sourcepub fn get_mut(&mut self, id: &str) -> Option<&mut dyn ChannelPlugin>
pub fn get_mut(&mut self, id: &str) -> Option<&mut dyn ChannelPlugin>
Get a mutable channel reference by ID
Sourcepub fn channel_ids(&self) -> Vec<&str>
pub fn channel_ids(&self) -> Vec<&str>
List all registered channel IDs
Trait Implementations§
Source§impl Default for ChannelManager
impl Default for ChannelManager
Source§fn default() -> ChannelManager
fn default() -> ChannelManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ChannelManager
impl !RefUnwindSafe for ChannelManager
impl Send for ChannelManager
impl Sync for ChannelManager
impl Unpin for ChannelManager
impl UnsafeUnpin for ChannelManager
impl !UnwindSafe for ChannelManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request