pub struct DocDefinition {
pub kind: String,
pub version: u64,
pub semantics: DocSemantics,
pub initial: Box<dyn Fn(&Value) -> Value + Send + Sync>,
pub migrate: Option<Box<dyn Fn(&JsonObject, u64) -> Result<Value, String> + Send + Sync>>,
pub checkpoint_when: Option<Box<dyn Fn(&DocDefinition, &Value, &[Op], CheckpointInfo) -> Result<bool, String> + Send + Sync>>,
}Expand description
A document definition. initial receives null (upstream’s family seed) and runs only when the document is
absent; migrate converts a stored value of an older version; checkpoint_when returning true
stores an ordinary change as a complete base instead of a delta.
Fields§
§kind: StringStable persisted kind; part of the public protocol.
version: u64Positive integer version of the stored value shape.
semantics: DocSemantics§initial: Box<dyn Fn(&Value) -> Value + Send + Sync>§migrate: Option<Box<dyn Fn(&JsonObject, u64) -> Result<Value, String> + Send + Sync>>§checkpoint_when: Option<Box<dyn Fn(&DocDefinition, &Value, &[Op], CheckpointInfo) -> Result<bool, String> + Send + Sync>>Implementations§
Source§impl DocDefinition
impl DocDefinition
pub fn new( kind: &str, version: u64, semantics: DocSemantics, initial: impl Fn(&Value) -> Value + Send + Sync + 'static, ) -> DocDefinition
pub fn migrate( self, migrate: impl Fn(&JsonObject, u64) -> Result<Value, String> + Send + Sync + 'static, ) -> Self
pub fn checkpoint_when( self, predicate: impl Fn(&DocDefinition, &Value, &[Op], CheckpointInfo) -> Result<bool, String> + Send + Sync + 'static, ) -> Self
Sourcepub fn define(self) -> Result<Doc, SessionError>
pub fn define(self) -> Result<Doc, SessionError>
Validate and share the definition (upstream defineDoc).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DocDefinition
impl !UnwindSafe for DocDefinition
impl Forget for DocDefinition
impl Freeze for DocDefinition
impl Move for DocDefinition
impl Send for DocDefinition
impl Sync for DocDefinition
impl Unpin for DocDefinition
impl UnsafeUnpin for DocDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more