pub struct SseState<T> {
pub sessions: Arc<DashMap<Uuid, SseSession<T>>>,
}Expand description
SSE state
Fields§
§sessions: Arc<DashMap<Uuid, SseSession<T>>>Implementations§
Source§impl<T> SseState<T>
impl<T> SseState<T>
pub fn add_session( &self, id: Uuid, data: Option<T>, sender: Sender<Event>, ) -> Option<SseSession<T>>
pub fn remove_session(&self, id: Uuid) -> Option<(Uuid, SseSession<T>)>
Sourcepub async fn send_message(&self, id: Uuid, data: Data) -> Option<()>
pub async fn send_message(&self, id: Uuid, data: Data) -> Option<()>
Sends a message to session id
Sourcepub async fn broadcast(&self, data: Data) -> usize
pub async fn broadcast(&self, data: Data) -> usize
Broadcast a message to all sessions and returns the number of sent messages
Sourcepub async fn broadcast_all_but(&self, id: Uuid, data: Data) -> usize
pub async fn broadcast_all_but(&self, id: Uuid, data: Data) -> usize
Broadcast a message to all sessions but one id and returns the number of sent messages
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SseState<T>
impl<T> !RefUnwindSafe for SseState<T>
impl<T> Send for SseState<T>
impl<T> Sync for SseState<T>
impl<T> Unpin for SseState<T>
impl<T> !UnwindSafe for SseState<T>
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> 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 more