pub enum Effect {
Create {
path: String,
markdown: String,
frontmatter: Option<Map<String, Value>>,
},
Insert {
into: Target,
at: At,
markdown: String,
expect: Option<EffectExpect>,
},
Set {
target: Target,
field: String,
value: Value,
expect: Option<EffectExpect>,
},
Unset {
target: Target,
field: String,
expect: Option<EffectExpect>,
},
MoveDocument {
target: Target,
to: String,
retarget_inbound: bool,
},
MoveBlocks {
targets: Vec<String>,
into: Target,
at: At,
expect: Option<EffectExpect>,
},
RemoveDocument {
target: Target,
},
RemoveBlocks {
targets: Vec<String>,
expect: Option<ExpectMap>,
},
Split {
target: String,
at: Vec<usize>,
expect: Option<EffectExpect>,
},
Merge {
targets: Vec<String>,
separator: Option<String>,
expect: Option<ExpectMap>,
},
Retarget {
repairs: Vec<Repair>,
path_glob: Option<String>,
},
}Expand description
§11 Effect: the nine public effects (two shapes each for move and
remove).
Variants§
Create
A new document at path from markdown and an optional frontmatter
mapping (composed as docs_create composes).
Insert
New blocks parsed from markdown into a document’s top level, a
section’s range or a container block, at at (default end).
Set
Write a field: frontmatter.<key> / content of a document,
markdown / attrs.checked of a block, an editable property of a
node.
Unset
Remove a document’s frontmatter.<key>.
MoveDocument
Rename a document (identity kept), rewriting the inbound links unless
retarget_inbound is false.
MoveBlocks
Move blocks under a new parent at a position.
RemoveDocument
Tombstone a document (nothing pooled).
RemoveBlocks
Remove blocks (subtrees).
Split
Split a block at byte offsets.
Merge
Merge blocks into the first (separator default " ", made explicit
once resolved).
Retarget
Rewrite link destinations repository-wide (links_repair).
Implementations§
Source§impl Effect
impl Effect
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
The wire form (§11.4 ResolvedEffect once resolved): op first,
at always present, separator present when set, optional keys
absent.
Sourcepub fn validate(v: &Value, i: usize) -> Result<Effect, String>
pub fn validate(v: &Value, i: usize) -> Result<Effect, String>
§11.1’s shape check of effects[i]: an unknown key, a missing or
mistyped member, a target kind the op does not take, a field not in
§11.2 — the message names effects[i] and the member (the surface
reports it as filter_invalid { reason, hint: "arguments" }).
Sourcepub fn validate_with(
v: &Value,
i: usize,
fix: Option<&ShapeFixContext<'_>>,
) -> Result<Effect, ShapeError>
pub fn validate_with( v: &Value, i: usize, fix: Option<&ShapeFixContext<'_>>, ) -> Result<Effect, ShapeError>
Effect::validate with the shape fixes of §8 (3.4): given a
ShapeFixContext — the request as written and the store’s row
lookup — the four shape mistakes carry their corrected call as
ShapeError::fix; without one the same errors carry none.
Sourcepub fn from_json(v: &Value) -> Result<Effect, String>
pub fn from_json(v: &Value) -> Result<Effect, String>
Parse one effect (its message names effects[0]).
Sourcepub fn list_from_json(v: &Value) -> Result<Vec<Effect>, String>
pub fn list_from_json(v: &Value) -> Result<Vec<Effect>, String>
Parse an effects array: a non-array or an empty list is a shape
error too.
Sourcepub fn expect(&self) -> Option<&EffectExpect>
pub fn expect(&self) -> Option<&EffectExpect>
The expect an effect carries, if any (not the per-block maps).