pub fn cas(
        &self,
        key: &T::Key,
        old: Option<&T::Value>,
        new: Option<&T::Value>,
    ) -> impl Future<Item = StdResult<(), Option<T::Value>>, Error = Error> {
        let client = self.client.clone();
        let key = write_key_future::<T>(key);
        let write_opt_value_future = |v: Option<&T::Value>| {
            match v {
                None => future::ok(None),
                Some(v) => future::result(bincode::serialize(v).map(Some).map_err(From::from)),
            }
        };
        let old = write_opt_value_future(old);
        let new = write_opt_value_future(new);
        key.join3(old, new)
            .and_then(move |(k, o, n)| client.cas(k, o, n).map_err(From::from))
            .and_then(|res| {
                match res {
                    Ok(()) => future::ok(Ok(())),
                    Err(None) => future::ok(Err(None)),
                    Err(Some(b)) => match bincode::deserialize(&b) {
                        Ok(v) => future::ok(Err(Some(v))),
                        Err(err) => future::err(From::from(err)),
                    }
                }
            })
    }
/// Compare and swap. Capable of unique creation, conditional modification, or deletion.
///
/// If old is None, this will only set the value if it doesn't exist yet. If new is None, will
/// delete the value if old is correct. If both old and new are Some, will modify the value if
/// old is correct.
///
/// If `Tree` is read-only, will do nothing.
Compare and swap. Capable of unique creation, conditional modification, or deletion.
If old is None, this will only set the value if it doesn't exist yet. If new is None, will
delete the value if old is correct. If both old and new are Some, will modify the value if
old is correct.

If `Tree` is read-only, will do nothing.
Compare and swap . Capable of unique creation conditional modification or deletion . If old is None this will only set the value if it doesn ' t exist yet . If new is None will delete the value if old is correct . If both old and new are Some will modify the value if old is correct . If ` Tree ` is read - only will do nothing .
pub fn cas(
        &self,
        key: &T::Key,
        old: Option<&T::Value>,
        new: Option<&T::Value>,
    ) -> impl Future<Item = StdResult<(), Option<T::Value>>, Error = Error> {
        let client = self.client.clone();
        let key = write_key_future::<T>(key);
        let write_opt_value_future = |v: Option<&T::Value>| {
            match v {
                None => future::ok(None),
                Some(v) => future::result(bincode::serialize(v).map(Some).map_err(From::from)),
            }
        };
        let old = write_opt_value_future(old);
        let new = write_opt_value_future(new);
        key.join3(old, new)
            .and_then(move |(k, o, n)| client.cas(k, o, n).map_err(From::from))
            .and_then(|res| {
                match res {
                    Ok(()) => future::ok(Ok(())),
                    Err(None) => future::ok(Err(None)),
                    Err(Some(b)) => match bincode::deserialize(&b) {
                        Ok(v) => future::ok(Err(Some(v))),
                        Err(err) => future::err(From::from(err)),
                    }
                }
            })
    }
pub fn cas ( & self , key : & T :: Key , old : Option < & T :: Value > , new : Option < & T :: Value > , ) -> impl Future < Item = StdResult < ( ) , Option < T :: Value > > , Error = Error > { let client = self . client . clone ( ) ; let key = write_key_future :: < T > ( key ) ; let write_opt_value_future = | v : Option < & T :: Value > | { match v { None => future :: ok ( None ) , Some ( v ) => future :: result ( bincode :: serialize ( v ) . map ( Some ) . map_err ( From :: from ) ) , } } ; let old = write_opt_value_future ( old ) ; let new = write_opt_value_future ( new ) ; key . join3 ( old , new ) . and_then ( move | ( k , o , n ) | client . cas ( k , o , n ) . map_err ( From :: from ) ) . and_then ( | res | { match res { Ok ( ( ) ) => future :: ok ( Ok ( ( ) ) ) , Err ( None ) => future :: ok ( Err ( None ) ) , Err ( Some ( b ) ) => match bincode :: deserialize ( & b ) { Ok ( v ) => future :: ok ( Err ( Some ( v ) ) ) , Err ( err ) => future :: err ( From :: from ( err ) ) , } } } ) }
Compare and swap.
Compare and swap .
&self
key
&T::Key
old
Option<&T::Value>
new
Option<&T::Value>
&self
key
&T::Key
old
Option<&T::Value>
new
Option<&T::Value>