[][src]Struct zookeeper_async::recipes::cache::PathChildrenCache

pub struct PathChildrenCache { /* fields omitted */ }

A Path Cache is used to watch a znode.

A utility that attempts to keep all data from all children of a ZK path locally cached. This will watch the ZK path; whenever a child is added, updated or removed, the Path Cache will change its state to contain the current set of children, the children's data and the children's state. You can register a listener that will get notified when changes occur.

Note

It is not possible to stay transactionally in sync. Users of this class must be prepared for false-positives and false-negatives. Additionally, always use the version number when updating data to avoid overwriting another process's change.

Implementations

impl PathChildrenCache[src]

pub async fn new<'_>(
    zk: Arc<ZooKeeper>,
    path: &'_ str
) -> ZkResult<PathChildrenCache>
[src]

Create a new cache instance watching path. If path does not exist, it will be created (see ZooKeeperExt::ensure_path).

Note

After creating the instance, you must call start.

pub async fn get_current_data<'_>(&'_ self) -> Data[src]

Return the current data. There are no guarantees of accuracy. This is merely the most recent view of the data.

pub async fn clear<'_>(&'_ self)[src]

pub fn start(&mut self) -> ZkResult<()>[src]

Start the cache. The cache is not started automatically. You must call this method.

pub fn add_listener<Listener: Fn(PathChildrenCacheEvent) + Send + 'static>(
    &self,
    subscriber: Listener
) -> Subscription
[src]

pub fn remove_listener(&self, sub: Subscription)[src]

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,