pub struct InMemorySink {
pub records: Arc<Mutex<Vec<NotificationRecord>>>,
/* private fields */
}Expand description
Test-only sink: stores every emitted record in an Arc<Mutex<Vec<_>>>
so the test can drain + assert without parsing log output. Optionally
returns a stubbed failure to exercise the dbus_failure_logged path.
Fields§
§records: Arc<Mutex<Vec<NotificationRecord>>>Records accumulated across every Self::show call. Tests
lock() + clone() to snapshot.
Implementations§
Source§impl InMemorySink
impl InMemorySink
Sourcepub fn with_failure(message: impl Into<String>) -> Self
pub fn with_failure(message: impl Into<String>) -> Self
Construct a sink that fails every show() with the given message.
Used by notification_dispatcher_handles_sink_failure.
Sourcepub fn snapshot(&self) -> Vec<NotificationRecord>
pub fn snapshot(&self) -> Vec<NotificationRecord>
Snapshot of the records vector. Convenient for assertions that don’t want to hold the lock.
Trait Implementations§
Source§impl Clone for InMemorySink
impl Clone for InMemorySink
Source§fn clone(&self) -> InMemorySink
fn clone(&self) -> InMemorySink
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 InMemorySink
impl Debug for InMemorySink
Source§impl Default for InMemorySink
impl Default for InMemorySink
Source§fn default() -> InMemorySink
fn default() -> InMemorySink
Returns the “default value” for a type. Read more
Source§impl NotificationSink for InMemorySink
impl NotificationSink for InMemorySink
Source§fn show<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
summary: &'life1 str,
body: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), NotificationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn show<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
summary: &'life1 str,
body: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), NotificationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Emit a single notification.
summary is the title; body is
already-sanitized HTML-escaped text suitable for daemons that
interpret a subset of HTML markup (KDE, GNOME).Auto Trait Implementations§
impl Freeze for InMemorySink
impl !RefUnwindSafe for InMemorySink
impl Send for InMemorySink
impl Sync for InMemorySink
impl Unpin for InMemorySink
impl UnsafeUnpin for InMemorySink
impl !UnwindSafe for InMemorySink
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