Struct zkstate::ZkState[][src]

pub struct ZkState<T: Serialize + DeserializeOwned + Send + Sync> { /* fields omitted */ }

Implementations

impl<T: Serialize + DeserializeOwned + Send + Sync + 'static> ZkState<T>[src]

pub fn new(
    zk: Arc<ZooKeeper>,
    zk_path: String,
    initial_state: T
) -> Result<Self>
[src]

pub fn update_handler<M: Fn(Change<Key, Value>) + Send + 'static>(
    &self,
    closure: M
) -> Result<(), ZkStructError>
[src]

Method to be invoked to handle state change notifications

pub fn update<M: FnOnce(&mut T)>(&self, closure: M) -> Result<(), ZkStructError>[src]

Update the shared object using a closure.

The closure is passed a reference to the contents of the ZkState. Once the closure returns, the shared state in Zookeeper is committed and the write locks released.

pub fn read(&self) -> Result<RwLockReadGuard<'_, T>, ZkStructError>[src]

Returns a Result<RwLockReadGuard>

pub fn c_read(&self)[src]

Consistent Read.

Preforms a check to make sure the local version is the same as the remote version before returning. If there is a mismatch, will preform a sync and return the latest object

pub fn metadata(&self) -> (usize, i32)[src]

Trait Implementations

impl<T: Clone + Serialize + DeserializeOwned + Send + Sync> Clone for ZkState<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for ZkState<T>

impl<T> Send for ZkState<T>

impl<T> Sync for ZkState<T>

impl<T> Unpin for ZkState<T>

impl<T> UnwindSafe for ZkState<T>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.