mod audit;
mod auth;
mod data_lock;
mod defaults;
mod delete_ops;
mod engine;
mod engine_introspection;
mod engine_ops;
mod engine_trace;
mod engine_types;
mod etag;
mod event;
mod ledger;
mod path;
mod read_cache;
mod state;
mod storage_class;
mod store;
#[cfg(test)]
mod test_support;
mod world;
mod world_ops;
pub(crate) use crate::state::*;
pub(crate) use crate::storage_class::*;
#[cfg(not(feature = "unstable-engine"))]
pub(crate) use auth::AuthGate;
#[cfg(feature = "unstable-engine")]
pub use auth::{is_valid_token, AuthGate};
pub(crate) use data_lock::acquire_data_root_writer_lock;
#[cfg(feature = "unstable-engine")]
pub use defaults::{
DEFAULT_LISTEN_REPLAY_MAX, DEFAULT_MAX_LISTEN_CONNECTIONS, DEFAULT_MAX_MEMORY_BYTES,
DEFAULT_MAX_WORLD_BYTES, DEFAULT_READ_CACHE_MAX_ENTRIES,
};
#[cfg(feature = "unstable-engine")]
#[doc(hidden)]
pub use engine::ShutdownToken;
#[cfg(feature = "unstable-engine")]
pub use engine::{Engine, EngineBuildError, EngineBuilder, EngineError};
#[cfg(feature = "unstable-engine")]
pub use engine_introspection::{
AuditBroken, AuditValid, AuditVerify, DfSnapshot, InvalidProcPath, PoolSnapshot, ProcEndpoint,
ValidatedProcPath, WorldUsage,
};
#[cfg(feature = "unstable-engine")]
pub use engine_trace::{DeleteMetadata, EngineDeleteTraceHooks, EngineWriteTraceHooks};
#[cfg(feature = "unstable-engine")]
pub use engine_types::{
parse_etag_matchers, AccessTier, ChangeEvent, ChangeVerb, EmptyKeyError, EngineSubscription,
EtagMatcher, InvalidWorldPath, Preconditions, ReadResult, Representation, SecretBytes,
SubscribePattern, SubscriptionRecvError, ValidatedWorldPath, WriteKind, WriteResult,
};
#[cfg(feature = "unstable-engine")]
pub use path::{validate_world_name, NAMESPACE_PREFIXES};
pub(crate) fn can_write(world_name: &str, tier: auth::Tier) -> bool {
let needs_approve = needs_write_approve(world_name);
match tier {
auth::Tier::Anon => false,
auth::Tier::Read => false,
auth::Tier::Write => !needs_approve,
auth::Tier::Approve => true,
}
}
pub(crate) fn needs_write_approve(world_name: &str) -> bool {
exact_or_child(world_name, "lib")
|| exact_or_child(world_name, "etc")
|| exact_or_child(world_name, "boot")
|| exact_or_child(world_name, "usr")
|| exact_or_child(world_name, "var/log")
}
pub(crate) fn can_delete(tier: auth::Tier) -> bool {
matches!(tier, auth::Tier::Approve)
}
pub(crate) fn exact_or_child(world_name: &str, prefix: &str) -> bool {
world_name == prefix
|| world_name
.strip_prefix(prefix)
.is_some_and(|rest| rest.starts_with('/'))
}
pub(crate) fn can_read(core: &Core, tier: auth::Tier) -> bool {
!core.tokens.read_required()
|| matches!(
tier,
auth::Tier::Read | auth::Tier::Write | auth::Tier::Approve
)
}