Struct servlin::EventSender
source · pub struct EventSender(pub Option<SyncSender<Event>>);Tuple Fields§
§0: Option<SyncSender<Event>>Implementations§
source§impl EventSender
impl EventSender
pub fn unconnected() -> Self
sourcepub fn send(&mut self, event: Event)
pub fn send(&mut self, event: Event)
Examples found in repository?
examples/events-sse.rs (line 56)
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
fn event_sender_thread(state: Arc<State>, permit: Permit) {
loop {
for n in 0..6 {
std::thread::sleep(Duration::from_secs(1));
// TODO: Rename Permit::wait and related functions to clarify that they are waiting for
// subordinates to drop.
// TODO: Add a method to wait for a permit to be revoked, and another with a timeout.
if permit.is_revoked() {
return;
}
for subscriber in state.subscribers.lock().unwrap().iter_mut() {
subscriber.send(Event::Message(n.to_string()));
}
}
state.subscribers.lock().unwrap().clear();
}
}pub fn disconnect(&mut self)
pub fn is_connected(&self) -> bool
Trait Implementations§
source§impl Clone for EventSender
impl Clone for EventSender
source§fn clone(&self) -> EventSender
fn clone(&self) -> EventSender
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for EventSender
impl Debug for EventSender
source§impl PartialEq for EventSender
impl PartialEq for EventSender
source§fn eq(&self, other: &EventSender) -> bool
fn eq(&self, other: &EventSender) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for EventSender
impl StructuralEq for EventSender
impl StructuralPartialEq for EventSender
Auto Trait Implementations§
impl RefUnwindSafe for EventSender
impl Send for EventSender
impl Sync for EventSender
impl Unpin for EventSender
impl UnwindSafe for EventSender
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