rift-mock-core 0.25.0

Rift core engine: imposter lifecycle, matching, behaviors, scripting and flow-state — usable in-process without the CLI or admin server.
Documentation
//! Mountebank-compatible imposter management for Rift.
//!
//! This module provides:
//! - `ImposterManager`: Lifecycle management for imposters
//! - `Imposter`: Individual imposter with its own port, rules, and state
//! - `ImposterConfig`: Configuration for creating imposters
//!
//! Each imposter binds to its own TCP port and maintains isolated state.
//!
//! ## Module Structure
//!
//! - `types`: All type definitions (structs, enums, errors)
//! - `predicates`: Predicate matching logic for stub matching
//! - `response`: Response building and execution
//! - `handler`: HTTP request handling for imposters
//! - `manager`: ImposterManager for lifecycle management
//! - `core`: Core Imposter struct and implementation

mod behavior_pipeline;
pub mod body_limits;
pub mod clock;
pub mod components;
mod conditional;
mod content_encoding;
mod core;
mod datadir_file;
pub mod events;
pub mod fault_io;
mod handler;
pub mod headers;
mod manager;
pub(crate) mod predicates;
pub mod probe;
pub(crate) mod reconcile;
mod response;
pub mod rng;
mod script_resolve;
mod status;
mod types;
pub(crate) use types::Gate;

#[cfg(test)]
mod tests;

// Re-export public types (used by external consumers like admin_api)
#[allow(unused_imports)]
pub use types::{
    AllowCors, ConditionalGet, ConditionalValidators, DebugImposter, DebugMatchResult,
    DebugRequest, DebugResponse, DebugResponsePreview, DebugStubInfo, Headers, ImposterConfig,
    ImposterError, IsResponse, LastModified, MAX_TRIED_STUBS, MatchOutcome, PathRewrite, PemList,
    Predicate, PredicateOperation, PredicateParameters, PredicateSelector, ProxyResponse,
    RecordedRequest, ResponseMode, RiftConfig, RiftConnectionPoolConfig, RiftErrorFault,
    RiftFaultConfig, RiftFlowStateConfig, RiftLatencyFault, RiftMetricsConfig, RiftProxyConfig,
    RiftResponseExtension, RiftScriptConfig, RiftScriptEngineConfig, RiftTcpFault,
    RiftUpstreamConfig, SingleHeaders, Stub, StubResponse, TriedStub, TriedWhy, WasmLimits,
    admission_check, admission_check_stub, check_imposter_rng_key, deserialize_replayed,
};

#[cfg(feature = "schema")]
pub(crate) use types::RESPONSE_VARIANT_KEYS;

// Re-export script `file:`/`ref:` resolution (issue #356)
#[cfg_attr(not(feature = "javascript"), allow(unused_imports))]
pub(crate) use script_resolve::{ConfinedPathError, read_confined, resolve_confined};
pub use script_resolve::{
    LookupFileError, ScriptBaseDir, ScriptFileAccess, ScriptResolveError, check_lookup_paths,
    open_lookup_file, read_lookup_file, resolve_lookup_path, resolve_scripts, resolve_stub_scripts,
};

// Re-export core imposter
#[allow(unused_imports)]
pub mod journal;
pub use journal::{
    DEFAULT_JOURNAL_MAX_BYTES, JournalEntry, JournalRead, JournalReadSince, LocalJournal,
    RequestJournal,
};

pub use core::Imposter;
pub(crate) use core::unread_generator_keys;
pub use datadir_file::sweep_interrupted_writes;
pub use probe::{FaultLayer, Generation, NoProbe, Point, Probe};
// Builds a `proxy`-stub upstream client under a trust policy (issue #974), so the binary and any
// embedder share one timeout/pooling configuration.
pub use core::build_upstream_client;
// The create-time dry run of `predicateGenerators` injects (issue #1580), for every door that
// admits a config from a client — rift-cluster's write path included.
pub use core::{
    ClearedProxyResponses, ClosestMatch, FailedPredicate, VerifyOptions, VerifyOutcome,
};
pub use core::{GeneratorDryRun, dry_run_predicate_generators};

// Re-export the imposter request handler (single-port gateway dispatch, issue #212)
pub use handler::{handle_imposter_request, handle_imposter_request_decorated};

// Re-export the embedder flow-store provider hook (issue #312)
pub use crate::extensions::flow_state::FlowStoreProvider;

// Re-export manager
pub use manager::{
    CursorFlusher, ImposterManager, PortReservation, PortTaken, ServerListener, TlsDefaults,
};
// Which clients the manager's imposters (and a front door over it) admit (issue #1523).
pub use crate::proxy::PeerPolicy;

// Re-export incremental reconciliation types (issue #316)
pub use events::{AdminEvent, AdminEventBus, AdminEventKind, ImposterAction};
pub use reconcile::{
    ApplyReport, DeleteAllReport, DesiredImposter, EventContext, ImposterEvent,
    ImposterEventListener, Persistence, stub_key,
};

// Re-export predicate utilities (used in tests and for external consumers)
#[allow(unused_imports)]
pub use predicates::{RequestHeaders, parse_query_string, predicate_matches, stub_matches};

// Re-export response utilities
pub use response::PreparedResponse;
#[allow(unused_imports)]
pub use response::create_response_preview;