zookeeper_async/
data.rs

1/// Statistics about a znode, similar to the UNIX `stat` structure.
2///
3/// # Time in ZooKeeper
4/// The concept of time is tricky in distributed systems. ZooKeeper keeps track of time in a number
5/// of ways.
6///
7/// - **zxid**: Every change to a ZooKeeper cluster receives a stamp in the form of a *zxid*
8///   (ZooKeeper Transaction ID). This exposes the total ordering of all changes to ZooKeeper. Each
9///   change will have a unique *zxid* -- if *zxid:a* is smaller than *zxid:b*, then the associated
10///   change to *zxid:a* happened before *zxid:b*.
11/// - **Version Numbers**: Every change to a znode will cause an increase to one of the version
12///   numbers of that node.
13/// - **Clock Time**: ZooKeeper does not use clock time to make decisions, but it uses it to put
14///   timestamps into the `Stat` structure.
15#[derive(Debug)]
16pub struct Stat {
17    /// The transaction ID that created the znode.
18    pub czxid: i64,
19    /// The last transaction that modified the znode.
20    pub mzxid: i64,
21    /// Milliseconds since epoch when the znode was created.
22    pub ctime: i64,
23    /// Milliseconds since epoch when the znode was last modified.
24    pub mtime: i64,
25    /// The number of changes to the data of the znode.
26    pub version: i32,
27    /// The number of changes to the children of the znode.
28    pub cversion: i32,
29    /// The number of changes to the ACL of the znode.
30    pub aversion: i32,
31    /// The session ID of the owner of this znode, if it is an ephemeral entry.
32    pub ephemeral_owner: i64,
33    /// The length of the data field of the znode.
34    pub data_length: i32,
35    /// The number of children this znode has.
36    pub num_children: i32,
37    /// The transaction ID that last modified the children of the znode.
38    pub pzxid: i64,
39}
40
41impl Stat {
42    /// Is the znode an ephemeral entry?
43    pub fn is_ephemeral(&self) -> bool {
44        self.ephemeral_owner != 0
45    }
46}