zwire 0.3.0

Zero-dependency, no_std-compatible transactional reactive state engine: scoped push-pull arena, rebaseable optimistic layers + STM drafts, exact incremental Top-K collections, and open @zwire/core wire protocols
Documentation
//! **zwire** — zero-dependency, `#![no_std]` (`alloc`) transactional reactive state engine
//! for Rust.
//!
//! Umbrella facade re-exporting:
//! - [`core`] (`zwire-core`) — Zero-global scoped push-pull arena & deadlock-free `SyncScope`
//! - [`tx`] (`zwire-tx`) — Rebaseable `OptimisticLayer`, RAII `OptimisticGuard`, atomic
//!   `try_settle`, and STM read-verify `Draft`
//! - [`collections`] (`zwire-collections`) — Exact 2-level Chunked B-Tree + `O(1)` Top-K
//! - [`protocol`] (`zwire-protocol`) — Zero-dep JSON `WireValue`, out-of-order hydration,
//!   `ExternalSource`, `SyncBridge`, and `InspectorHook` compatible with `@zwire/core`
//! - [`ReactiveCollection`] — First-class reactive `top_k_signal(k)` bridging `collections` + `core`

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

#[cfg(feature = "core")]
pub mod optics;
#[cfg(feature = "core")]
pub mod resource;
#[cfg(feature = "core")]
pub mod store;

#[cfg(feature = "derive")]
pub use zwire_derive::ReactiveStore;

#[cfg(feature = "collections")]
pub use zwire_collections as collections;
#[cfg(feature = "core")]
pub use zwire_core as core;
#[cfg(feature = "protocol")]
pub use zwire_protocol as protocol;
#[cfg(feature = "tx")]
pub use zwire_tx as tx;

#[cfg(all(feature = "core", feature = "collections"))]
mod pure_reactive_collection;
#[cfg(all(feature = "core", feature = "collections"))]
pub use pure_reactive_collection::PureReactiveCollection;

#[cfg(all(feature = "core", feature = "collections"))]
mod reactive_collection;
#[cfg(all(feature = "core", feature = "collections"))]
pub use reactive_collection::ReactiveCollection;

#[cfg(all(feature = "sync", feature = "collections"))]
mod sync_pure_reactive_collection;
#[cfg(all(feature = "sync", feature = "collections"))]
pub use sync_pure_reactive_collection::SyncPureReactiveCollection;

#[cfg(all(feature = "sync", feature = "collections"))]
mod sync_reactive_collection;
#[cfg(all(feature = "sync", feature = "collections"))]
mod sync_top_k;
#[cfg(all(feature = "sync", feature = "collections"))]
pub use sync_reactive_collection::SyncReactiveCollection;

#[cfg(all(feature = "tx", feature = "collections"))]
mod transactional_collection;
#[cfg(all(feature = "tx", feature = "collections"))]
pub use transactional_collection::{RowEdit, TransactionalCollection};

/// Convenient re-exports of the most commonly used `zwire` primitives.
pub mod prelude {
    #[cfg(feature = "derive")]
    pub use crate::ReactiveStore;
    #[cfg(all(feature = "tx", feature = "collections"))]
    pub use crate::TransactionalCollection;
    #[cfg(feature = "collections")]
    pub use crate::collections::{AcceptAll, Collection, KeyedCollection, TopKViewId};
    #[cfg(feature = "core")]
    pub use crate::core::{
        Atom, AtomOptions, BatchGuard, Computed, ComputedOptions, CoreError, EvalContext,
        HookGuard, NodeId, Owner, OwnerId, Scope, ScopeMode, Signal, Subscription, WatchOptions,
        WeakScope,
    };
    #[cfg(feature = "sync")]
    pub use crate::core::{
        SyncAtom, SyncAtomOptions, SyncBatchGuard, SyncCleanupFn, SyncComputed,
        SyncComputedOptions, SyncEvalContext, SyncHookGuard, SyncOwner, SyncScope, SyncSignal,
        SyncSubscription, WeakSyncScope,
    };
    #[cfg(feature = "core")]
    pub use crate::optics::Lens;
    #[cfg(feature = "protocol")]
    pub use crate::protocol::{
        ExternalSource, HydratedState, InspectorHook, PatchOrigin, StatePatch, SyncAdapter,
        SyncBridge, SyncBridgeOptions, WireCodec, WireValue, attach_inspector, create_sync_bridge,
        dehydrate, dehydrate_json, from_external_source, hydratable, hydrate, hydrate_json,
    };
    #[cfg(all(feature = "protocol", feature = "sync"))]
    pub use crate::protocol::{
        SyncExternalSource, SyncInspectorGuard, SyncInspectorHook, ThreadSyncAdapter,
        ThreadSyncBridge, attach_sync_inspector, create_thread_sync_bridge,
        from_sync_external_source, register_sync_hydratable, sync_dehydrate, sync_dehydrate_json,
        sync_hydratable, sync_hydrate, sync_hydrate_json,
    };
    #[cfg(feature = "core")]
    pub use crate::resource::{Resource, ResourceState};
    #[cfg(feature = "core")]
    pub use crate::store::{MapStore, projection};
    #[cfg(feature = "tx")]
    pub use crate::tx::{
        Draft, DraftBase, DraftError, OptimisticGuard, OptimisticLayer, run_optimistic,
    };
    #[cfg(all(feature = "sync", feature = "tx"))]
    pub use crate::tx::{
        SyncDraft, SyncOptimisticGuard, SyncOptimisticLayer, SyncSettlement, run_sync_optimistic,
    };
    #[cfg(all(feature = "core", feature = "collections"))]
    pub use crate::{PureReactiveCollection, ReactiveCollection};
    #[cfg(all(feature = "sync", feature = "collections"))]
    pub use crate::{SyncPureReactiveCollection, SyncReactiveCollection};
}

#[cfg(all(
    doctest,
    feature = "std",
    feature = "core",
    feature = "tx",
    feature = "collections",
    feature = "protocol"
))]
#[doc = include_str!("../README.md")]
mod readme_doctests {}