Skip to main content

Effect

Enum Effect 

Source
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).

Fields

§path: String
§markdown: String
§frontmatter: Option<Map<String, Value>>
§

Insert

New blocks parsed from markdown into a document’s top level, a section’s range or a container block, at at (default end).

Fields

§into: Target
§at: At
§markdown: String
§

Set

Write a field: frontmatter.<key> / content of a document, markdown / attrs.checked of a block, an editable property of a node.

Fields

§target: Target
§field: String
§value: Value
§

Unset

Remove a document’s frontmatter.<key>.

Fields

§target: Target
§field: String
§

MoveDocument

Rename a document (identity kept), rewriting the inbound links unless retarget_inbound is false.

Fields

§target: Target
§retarget_inbound: bool
§

MoveBlocks

Move blocks under a new parent at a position.

Fields

§targets: Vec<String>
§into: Target
§at: At
§

RemoveDocument

Tombstone a document (nothing pooled).

Fields

§target: Target
§

RemoveBlocks

Remove blocks (subtrees).

Fields

§targets: Vec<String>
§

Split

Split a block at byte offsets.

Fields

§target: String
§

Merge

Merge blocks into the first (separator default " ", made explicit once resolved).

Fields

§targets: Vec<String>
§separator: Option<String>
§

Retarget

Rewrite link destinations repository-wide (links_repair).

Fields

§repairs: Vec<Repair>
§path_glob: Option<String>

Implementations§

Source§

impl Effect

Source

pub const fn name(&self) -> &'static str

The effect’s op.

Source

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.

Source

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" }).

Source

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.

Source

pub fn from_json(v: &Value) -> Result<Effect, String>

Parse one effect (its message names effects[0]).

Source

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.

Source

pub fn expect(&self) -> Option<&EffectExpect>

The expect an effect carries, if any (not the per-block maps).

Source

pub fn describe(&self) -> String

describe (§11.3): the words a dropped duplicate’s diagnostic uses — set <field> on document <id>, move block b_1,block b_2, ….

Trait Implementations§

Source§

impl Clone for Effect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Effect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Effect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Effect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.