[][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>>


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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<I> IntoIterator for I where
    I: Iterator

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>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.