pipecircuit 0.0.18

Correct. Robust. Fast. Portable. Pick four.
Documentation
//! Bounded observation of one authoritative table.
//!
//! Mutation is available only through the observed owner. Projections must be
//! deterministic functions of the supplied row and immutable parameters; shared
//! interior mutation of stored values is not an observed edit.

//!
//! A remote full copy is a projection that includes every row. Mutation,
//! publication, and transport admission are distinct boundaries:
//!
//! ```
//! use core::num::{NonZeroU32, NonZeroU64};
//! use pipecircuit::storage::warp_table::{Capacity, WarpTable, WarpTableRow};
//! use pipecircuit::storage::warp_table::observed::{
//!     SourceId, ViewId, ViewDefinition, ViewDelivery, ViewAdmission,
//! };
//!
//! #[derive(WarpTableRow)]
//! #[index(primary = u32)]
//! struct Actor { position: u32, private: u32 }
//! struct PublicPosition;
//! impl ViewDefinition<Actor> for PublicPosition {
//!     type Value = u32;
//!     fn project(&self, row: ActorRef<'_>) -> Option<u32> {
//!         Some(*row.position)
//!     }
//! }
//!
//! # fn main() -> Result<(), &'static str> {
//! let table = WarpTable::<Actor>::try_new(Capacity::new(NonZeroU32::MIN))
//!     .map_err(|_| "table capacity")?;
//! let mut source = table.observe(SourceId::new(NonZeroU64::MIN))
//!     .map_err(|_| "observation storage")?;
//! let mut view = source.maintain(ViewId::new(NonZeroU64::MIN), PublicPosition)
//!     .map_err(|_| "view storage")?;
//! source.insert_with_id(7, Actor { position: 42, private: 99 })
//!     .map_err(|_| "source sequence exhausted")?;
//! view.refresh(&source).map_err(|_| "publication refused")?;
//!
//! let mut subscriber = view.subscribe();
//! let mut scratch = view.delivery_buffer().map_err(|_| "delivery storage")?;
//! view.transmit(&mut subscriber, &mut scratch, |delivery| {
//!     match delivery {
//!         ViewDelivery::Baseline { through: _, rows } => {
//!             // A real carrier encodes or owns these rows before admission.
//!             assert_eq!(rows.map(|row| *row.value).collect::<Vec<_>>(), [42]);
//!         }
//!         ViewDelivery::Changes { .. } | ViewDelivery::Current { .. } => {}
//!     }
//!     // Nothing was retained by this illustrative carrier. Retry later.
//!     Ok::<_, ()>(ViewAdmission::Backpressured)
//! }).map_err(|_| "transport failure")?;
//! assert_eq!(subscriber.admitted_through(), None);
//! # Ok(())
//! # }
//! ```
//!
//! The definition controls disclosure: private fields need never enter the
//! projection, history, or codec. Changing definition parameters explicitly
//! starts a new epoch. The codec must validate its own byte/field bounds and
//! schema version before applying decoded messages to [`ViewReplica`].
//! Each source incarnation and each view definition need distinct identities.
//! These IDs identify continuity, not authentication.

mod change;
mod delivery;
pub use delivery::{
    ViewAdmission, ViewDeliveryBuffer, ViewDeliveryError, ViewSubscription, ViewTransmitError,
    ViewTransmitOutcome,
};

mod count;
pub use count::{CountPublication, CountRefreshOutcome, MaintainedCount};

mod replica;
pub use replica::{
    PreparedReplicaUpdate, ViewApplyError, ViewApplyOutcome, ViewBaselinePreparation,
    ViewConnection, ViewPreparation, ViewReplica, ViewReplicaStatus,
};

mod source;
mod view;

#[cfg(feature = "secondary-indexes")]
pub use source::ObservationSelectionError;
pub use source::{ObservationCreationError, ObservationEditError, ObservedTable, SourceId};
pub use view::{
    MaintainedView, PreparedViewRefresh, ViewChange, ViewColumnStorageError, ViewCreationError,
    ViewDefinition, ViewDelivery, ViewId, ViewPublication, ViewRefreshError, ViewRefreshOutcome,
    ViewRevision, ViewRow, ViewRows,
};

#[cfg(test)]
mod tests;

#[cfg(kani)]
mod proofs;