Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    // Required methods
    fn apply(&mut self, op: EditOp) -> Result<(), BackendError>;
    fn to_value(&self) -> Result<Value, BackendError>;
    fn source(&self) -> Result<String, BackendError>;

    // Provided method
    fn schema(&self) -> Option<Schema> { ... }
}
Expand description

The editing surface Model drives. Implementors own the document’s bytes and apply edits losslessly.

Required Methods§

Source

fn apply(&mut self, op: EditOp) -> Result<(), BackendError>

Apply one edit. Atomic: on Err, the document is unchanged.

Source

fn to_value(&self) -> Result<Value, BackendError>

The current value tree to render (for an embed backend, the metadata region — not the whole host file).

Source

fn source(&self) -> Result<String, BackendError>

The canonical serialized form the embedder persists on save (for an embed backend, the full rendered host file).

Provided Methods§

Source

fn schema(&self) -> Option<Schema>

The schema governing this document, if the backend knows one. The backend is exactly the component that knows where the document came from, so it is the right place to know what governs it — a prov backend returns the schema resolved from the workspace config; a standalone config file has none. Defaulted to None so existing backends are unaffected.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§