willow-data-model 0.7.0

The core datatypes of Willow, an eventually consistent data store with improved distributed deletion.
Documentation
#![doc(html_logo_url = "https://willowprotocol.org/assets/willow_emblem_standalone.png")]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(async_fn_in_trait)]

//! # Willow Data Model
//!
//! This crate implements the [Willow Data Model](https://willowprotocol.org/specs/data-model/), with plenty of generics to account for all the [data model parameters](https://willowprotocol.org/specs/data-model/index.html#willow_parameters).
//!
//! As an application developer, you likely do not need to interact with this crate explicitly — use the [`willow25`](https://crates.io/crates/willow25) crate instead, which wraps this crate with ready-to-use non-generic types. As a library author, this crate *is* the right place. Code library functions against the types and interfaces provided by this crate, so that your code can be used both by other generic code and by code specialised to any particular instantiation of the Willow protocols.
//!
//! Many trait methods in this crate have a name starting with `wdm` (Willow Data Model). This naming convention ensures that there are no naming conflicts with methods provided by types which specialise Willow to a particular set of parameters (such as the types of the [`willow25`](https://crates.io/crates/willow25) crate). This is slightly inconvenient when writing generic code, but ensures that application developers who only interact with specialised types  get the smoothest possible development experience.
//!
//! Note: we will likely deprecate this crate at some point in the future, and implement Willow25 directly without any generics. See [here](https://worm-blossom.org/#y2026w9a4) for the reasoning. We already stopped providing generic implementations of certain features, for example, the `willow25` crate provides entry storage functionality that has no counterpart in this crate.

pub mod paths;

pub mod entry;

mod timestamp;
pub use timestamp::Timestamp;

pub mod groupings;

pub mod authorisation;

#[cfg(feature = "dev")]
pub mod test_parameters;

/// A “prelude” for crates using the `willow_data_model` crate.
///
/// This prelude is similar to the standard library’s prelude in that you’ll almost always want to import its entire contents, but unlike the standard library’s prelude you’ll have to do so manually:
///
/// `use willow_data_model::prelude::*;`
///
/// The prelude may grow over time.
pub mod prelude {
    pub use super::authorisation::*;
    pub use super::entry::{Entry, EntryBuilder, Entrylike, EntrylikeExt};
    pub use super::groupings::*;
    pub use super::paths::{
        Component, InvalidComponentError, OwnedComponent, Path, PathBuilder, PathError,
        PathFromComponentsError,
    };
    pub use super::timestamp::Timestamp;
    pub use hifitime::prelude::*;

    #[cfg(feature = "dev")]
    pub use super::test_parameters::*;
}

/// Checks if a bit of a given byte is flagged at a particular index (with 0 being the most significant bit).
pub(crate) fn is_bitflagged(byte: u8, index: usize) -> bool {
    byte & (1u8 << (7 - index)) != 0u8
}