[][src]Struct sled::Subscriber

pub struct Subscriber { /* fields omitted */ }

A subscriber listening on a specified prefix

Subscriber implements both Iterator<Item = Event> and Future<Output=Option<Event>>

Examples

Synchronous, blocking subscriber:

use sled::{Config, Event};
let config = Config::new().temporary(true);

let tree = config.open()?;

// watch all events by subscribing to the empty prefix
let mut subscriber = tree.watch_prefix(vec![]);

let tree_2 = tree.clone();
let thread = std::thread::spawn(move || {
    tree.insert(vec![0], vec![1])
});

// `Subscription` implements `Iterator<Item=Event>`
for event in subscriber.take(1) {
    match event {
        Event::Insert{ key, value } => assert_eq!(key.as_ref(), &[0]),
        Event::Remove {key } => {}
    }
}

Aynchronous, non-blocking subscriber:

Subscription implements Future<Output=Option<Event>>.

while let Some(event) = (&mut subscriber).await { /* use it */ }

Trait Implementations

impl Drop for Subscriber[src]

impl Future for Subscriber[src]

type Output = Option<Event>

The type of value produced on completion.

impl Iterator for Subscriber[src]

type Item = Event

The type of the elements being iterated over.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.