use std::cell::OnceCell;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use crate::backend::{BackendError, MemBackend};
use crate::engine_fallback_type;
use crate::entity::EntityId;
use crate::entity::generator::generate_markdown;
use crate::entity::loader::parse_entries;
use crate::entity::store_builder::push_entities_into_store;
use crate::mem::MemOrigin;
use crate::ops::WarningHint;
use crate::workspace::{Mount, MountStorage, WorkspaceSettings};
use super::boot::collect_source_entries;
use super::{BackendFactory, Engine, EngineError, GitBranchOps, MountedBackend};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SchemaStaging {
AlreadyResolvable,
Staged,
NoEmbeddedSchema,
CarriedByArchive,
}
impl Engine {
pub fn set_settings(&mut self, settings: WorkspaceSettings) {
self.settings = settings;
self.create_rule_set_memo = OnceCell::new();
}
pub fn set_backend_factory(&mut self, factory: BackendFactory) {
self.backend_factory = factory;
}
pub(crate) fn schemas_insert(
&mut self,
mem: String,
schema: std::sync::Arc<memstead_schema::Schema>,
) {
self.schemas_epoch += 1;
self.schemas.insert(mem, schema);
}
pub(crate) fn schemas_remove(&mut self, mem: &str) {
self.schemas_epoch += 1;
self.schemas.remove(mem);
}
pub fn set_unmounted_storage_prober(&mut self, prober: super::UnmountedStorageProber) {
self.unmounted_storage_prober = Some(prober);
}
pub fn set_mutation_clock(&mut self, clock: crate::engine::MutationClock) {
self.mutation_clock = clock;
}
pub fn set_role(&mut self, role: crate::vcs::Role) {
self.current_role = role;
}
pub fn current_role(&self) -> crate::vcs::Role {
self.current_role
}
pub fn set_identity(&mut self, identity: Option<String>) {
self.current_identity = identity;
}
pub fn set_actor(&mut self, actor: crate::vcs::Actor) {
self.current_actor = actor;
}
pub fn current_actor(&self) -> crate::vcs::Actor {
self.current_actor
}
pub fn set_client(&mut self, client: Option<crate::vcs::ClientId>) {
self.current_client = client;
}
pub fn current_client(&self) -> Option<&crate::vcs::ClientId> {
self.current_client.as_ref()
}
pub fn commit_context<'a>(
&self,
tool: Option<&'a str>,
actor: crate::vcs::Actor,
client: Option<crate::vcs::ClientId>,
note: Option<String>,
) -> crate::vcs::CommitContext<'a> {
crate::vcs::CommitContext::new(
tool,
actor,
client,
note,
self.current_role,
self.current_identity.clone(),
)
}
pub fn session_commit_context<'a>(
&self,
tool: Option<&'a str>,
note: Option<String>,
) -> crate::vcs::CommitContext<'a> {
self.commit_context(tool, self.current_actor, self.current_client.clone(), note)
}
pub fn current_identity(&self) -> Option<&str> {
self.current_identity.as_deref()
}
pub(crate) fn now_iso(&self) -> String {
crate::engine::mutation::iso_from_system_time((self.mutation_clock)())
}
pub fn set_git_branch_ops(&mut self, ops: GitBranchOps) {
self.git_branch_ops = Some(ops);
}
}
mod export;
mod mem_settings;
mod mounts;
mod reload;
mod schema;
mod schema_pin;
pub use schema_pin::*;
#[cfg(test)]
mod tests;