pub struct ProvBackend { /* private fields */ }Expand description
A backend over a single prov document, editing its embedded metadata.
Implementations§
Source§impl ProvBackend
impl ProvBackend
Sourcepub fn open(
path: impl Into<PathBuf>,
text: impl Into<String>,
) -> Result<Self, BackendError>
pub fn open( path: impl Into<PathBuf>, text: impl Into<String>, ) -> Result<Self, BackendError>
Open a prov document from its full text, with no schema. Errors if prov
cannot parse it.
Sourcepub fn open_with_schema(
path: impl Into<PathBuf>,
text: impl Into<String>,
schema: Schema,
) -> Result<Self, BackendError>
pub fn open_with_schema( path: impl Into<PathBuf>, text: impl Into<String>, schema: Schema, ) -> Result<Self, BackendError>
Open a prov document carrying the workspace schema — the prov-aware path,
so the flower model validates controlled fields and offers pickers.
Sourcepub fn body(&self) -> Result<String, BackendError>
pub fn body(&self) -> Result<String, BackendError>
The prose body outside the metadata block — the region a leaf editor
would own. Empty for a whole-file config document.
Sourcepub fn has_body(&self) -> Result<bool, BackendError>
pub fn has_body(&self) -> Result<bool, BackendError>
Whether the document has an editable prose body (a fenced carrier). A whole-file config document has none — its body cannot be replaced.
Sourcepub fn set_body(&mut self, body: &str) -> Result<(), BackendError>
pub fn set_body(&mut self, body: &str) -> Result<(), BackendError>
Replace the prose body, leaving the metadata block untouched — the write
path for edits a leaf editor makes to body.
Uses fig’s Embed::replace_body (the same lossless primitive prov edits
through). A frontend that wants fixity/updated restamping routes this
through prov’s write path instead; here it demonstrates that the metadata
and body regions edit independently over one document.
Trait Implementations§
Source§impl Backend for ProvBackend
impl Backend for ProvBackend
Source§fn apply(&mut self, op: EditOp) -> Result<(), BackendError>
fn apply(&mut self, op: EditOp) -> Result<(), BackendError>
Err, the document is unchanged.Source§fn to_value(&self) -> Result<Value, BackendError>
fn to_value(&self) -> Result<Value, BackendError>
Source§fn source(&self) -> Result<String, BackendError>
fn source(&self) -> Result<String, BackendError>
Source§fn schema(&self) -> Option<Schema>
fn schema(&self) -> Option<Schema>
None so existing backends are unaffected.