pub struct SchemaCopy<M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
Exclusive source/target custody for a key-preserving whole-database transformation. Both allocations remain closed to ordinary access. Dropping preserves progress. Publication requires completed validation. Allocation reuse remains unsupported.
Implementations§
Source§impl<M: Memory> SchemaCopy<M>
impl<M: Memory> SchemaCopy<M>
Sourcepub fn resume(
source_memory: RuntimeMemory<M>,
target_memory: RuntimeMemory<M>,
source_schema: Schema,
target_schema: Schema,
expected: &SchemaTransition,
) -> Result<Self, Error>
pub fn resume( source_memory: RuntimeMemory<M>, target_memory: RuntimeMemory<M>, source_schema: Schema, target_schema: Schema, expected: &SchemaTransition, ) -> Result<Self, Error>
Sourcepub fn next_entity(&self) -> Option<&'static str>
pub fn next_entity(&self) -> Option<&'static str>
Name of the next entity to copy, in canonical schema-name order.
Returns None after copying or once cancellation/validation has started.
Sourcepub fn copy_unchanged<E: Entity>(
&mut self,
limit: usize,
bytes: usize,
) -> Result<CopyStep, Error>
pub fn copy_unchanged<E: Entity>( &mut self, limit: usize, bytes: usize, ) -> Result<CopyStep, Error>
Explicitly preserve an unchanged entity through the same bounded copy path. The entity’s complete declaration must be admitted by both schemas.
§Errors
Refuses changed declarations, wrong copy order, bounds or corrupt source rows.
§Panics
Supplier mutation failures trap and roll back the whole IC message.
Sourcepub fn copy_next<S: Entity, T: Entity>(
&mut self,
limit: usize,
bytes: usize,
transform: fn(S, &[u8]) -> Result<T, Error>,
) -> Result<CopyStep, Error>
pub fn copy_next<S: Entity, T: Entity>( &mut self, limit: usize, bytes: usize, transform: fn(S, &[u8]) -> Result<T, Error>, ) -> Result<CopyStep, Error>
Transform the next bounded source page and checkpoint its target inserts.
The function must be deterministic for the declared version/fixed inputs,
synchronous and free of external effects or reentrant database mutations.
Limits match source paging: 1..=32 candidates, 1 byte..=128 KiB source output.
Target preparation additionally enforces the ordinary batch/index envelope.
Managed timestamp roles and their values must be preserved; field renames
are allowed through the explicit transformation. No insertion clock runs.
Call for next_entity() only. Completion advances to the next schema entity;
complete becomes true only after all entities have been copied.
Repeated calls after completion return zero rows and complete = true.
§Errors
Refusals (including transform errors, changed keys and cross-page uniqueness collisions) leave both rows and progress unchanged. Cancelling refuses copying.
§Panics
Mutation failures or a later enclosing-message trap roll back the whole chunk on the IC. Native callers must discard the runtime after a mutation panic.
Sourcepub fn cancel_step(&mut self, limit: usize) -> Result<bool, Error>
pub fn cancel_step(&mut self, limit: usize) -> Result<bool, Error>
Remove at most 1..=32 target entries, retaining its ownership tombstone. Copying cannot resume once cleanup starts. Return true only after cleanup and restoration of the source live manifest; drop this handle before reopen. No physical shrink or target allocation reuse is promised.
§Errors
Refuses invalid limits before mutation.
§Panics
Supplier mutation failures trap and roll back the entire IC message.
Sourcepub fn validate_next(&mut self, limit: usize) -> Result<bool, Error>
pub fn validate_next(&mut self, limit: usize) -> Result<bool, Error>
Validate at most 1..=32 physical source or target entries in one call. Checks complete row framing, exact key coverage in both directions, revision metadata, expected index membership and every stored index’s owner/key. Each row has at most eight indexes and sixteen references. Each pass first checks all declared revisions (at most 32), including empty entities. No writes to rows/indexes occur; only successful bounded progress is checkpointed. Return true only after both passes finish. Copying cannot resume afterward.
§Errors
Refuses before copy completion, during cancellation, or on limits/corruption. A refused chunk leaves its durable validation position unchanged.
§Panics
Supplier failures trap; an IC trap rolls back checkpoint advancement.
Sourcepub fn publish(self) -> Result<Database<M>, Error>
pub fn publish(self) -> Result<Database<M>, Error>
Atomically retire source admission and publish the fully validated target.
The host selects the target allocation for subsequent ordinary opens.
Source rows remain preserved but closed: this is not an operational rollback
promise after target writes. Explicit RetiredSource cleanup may remove them.
§Errors
Refuses unless both validation passes have completed.
§Panics
Mutation failures or a later enclosing-message trap roll back both manifests.