Skip to main content

Path

Struct Path 

Source
pub struct Path<R, T> { /* private fields */ }
Expand description

The location of a T inside the record R. See the module docs.

Implementations§

Source§

impl<R, T: Model + Identified, S> Path<R, Items<T, S>>

Source

pub fn item(&self, id: &Id) -> T::Paths<R>

The item id, its own paths rooted here.

Source

pub fn item_path(&self, id: &Id) -> Path<R, T>

Source

pub fn remove(&self, id: &Id) -> Edit<R>

Source§

impl<R, T: Model + Identified> Path<R, Keyed<T>>

Source

pub fn upsert(&self, before: Option<&T>, after: &T) -> Vec<Edit<R>>

The edits that make the item after what it is: added when before is None, else changed field by field from before.

Source

pub fn insert(&self, item: &T) -> Edit<R>

Add item under its own id.

Source§

impl<R, T: Model> Path<R, Map<T>>

Source

pub fn key(&self, key: impl Into<String>) -> T::Paths<R>

The entry key, its own paths rooted here.

Source

pub fn remove(&self, key: impl Into<String>) -> Edit<R>

Remove the entry key.

Source§

impl<R, T: Model + Identified> Path<R, Ordered<T>>

Source

pub fn insert(&self, at: usize, item: &T) -> Edit<R>

Add item under its own id at position at.

Source

pub fn move_to(&self, id: &Id, at: usize) -> Edit<R>

Move the item id to position at.

Source§

impl<R> Path<R, R>

Source

pub const fn root() -> Self

The record itself.

Source§

impl<R: Model, T> Path<R, T>

Source

pub fn object(&self, doc: &Doc) -> Option<ObjId>

The object the value at this path is stored in — a record’s map, a list, a text — resolved through each container’s own layout, for an editor that binds to the object itself (a rich-text field inside a collection item); None when absent or stored as a scalar.

Source§

impl<R, T> Path<R, T>

Source

pub fn from_segments(segments: Vec<Segment>) -> Self

A path from stored segments. A path read back from storage or the wire is checked when an edit at it applies.

Source

pub fn segments(&self) -> &[Segment]

Source

pub fn into_segments(self) -> Vec<Segment>

Source

pub fn under<P>(&self, prefix: &Path<P, R>) -> Path<P, T>

This path, rooted at an item, seen from the record containing it: a row’s favorite as Snippets › snippets › <id> › favorite.

Source

pub fn get<'a>(&self, root: &'a R) -> Option<&'a T>
where R: Model + 'static, T: 'static,

The value at this path in root, if it is there.

Source

pub fn starts_with<U>(&self, other: &Path<R, U>) -> bool

Whether self is other or lies inside it.

Source

pub fn edits(&self, before: &T, after: &T) -> Vec<Edit<R>>
where T: Model,

The field edits that turn before, the value at this path, into after: what a surface that edited a local copy submits, field by field and item by item (Model::diff).

Source

pub fn edit(&self, op: EditOp) -> Edit<R>

The edit op at this path.

Source§

impl<R, T: Settable> Path<R, T>

Source

pub fn set(&self, value: T) -> Edit<R>

Replace the value.

Source§

impl<R, T: Operations> Path<R, T>

Source

pub fn perform(&self, op: &T::Op) -> Result<Edit<R>, Error>

The edit op of the value at this path, in the type’s own vocabulary.

§Errors

Returns the serialization error of op.

Source§

impl<R, T: Model> Path<R, Option<T>>

Source

pub fn some(&self) -> T::Paths<R>

The value when present; edits at it refuse while it is absent.

Source§

impl<R> Path<R, String>

Source

pub fn splice( &self, at: usize, delete: usize, insert: impl Into<String>, ) -> Edit<R>

Replace delete characters at at with insert.

Source

pub fn replace(&self, text: impl Into<String>) -> Edit<R>

Replace the whole text, written as the smallest splice that turns the stored text into it.

Source§

impl<R> Path<R, Counter>

Source

pub fn add(&self, by: i64) -> Edit<R>

Add by (negative to subtract). Concurrent additions add up.

Source§

impl<R, T: Model> Path<R, Set<T>>

Source

pub fn insert(&self, value: &T) -> Edit<R>

Add an element.

Source

pub fn remove(&self, value: &T) -> Edit<R>

Remove an element.

Source§

impl<R, T: Model> Path<R, Collection<T>>

Source

pub fn item(&self, id: &Id) -> T::Paths<R>

The item id, its own paths rooted here.

Source

pub fn item_path(&self, id: &Id) -> Path<R, T>

The path of the item id itself.

Source

pub fn insert(&self, at: usize, value: &T) -> Edit<R>

Insert value at at (clamped to the end) under a fresh id minted when the edit applies.

Source

pub fn insert_as(&self, id: &Id, at: usize, value: &T) -> Edit<R>

Insert value at at (clamped to the end) under id.

Source

pub fn remove(&self, id: &Id) -> Edit<R>

Remove the item id.

Source

pub fn move_to(&self, id: &Id, at: usize) -> Edit<R>

Move the item id to at (clamped to the end).

Source

pub fn upsert_by(&self, matching: Map<String, Value>, value: Value) -> Edit<R>

Update the one item whose fields hold matching with the fields of value, else append value with them (EditOp::UpsertItem).

Source§

impl<R, T: Model> Path<R, BTreeMap<String, T>>

Source

pub fn key(&self, key: impl Into<String>) -> T::Paths<R>

The entry key, its own paths rooted here.

Source

pub fn remove(&self, key: impl Into<String>) -> Edit<R>

Remove the entry key.

Source§

impl<R, T: Model> Path<R, Grid<T>>

Source

pub fn cell(&self, row: &Id, column: &Id) -> T::Paths<R>

The cell at row, column, its own paths rooted here.

Source

pub fn set_cell(&self, row: &Id, column: &Id, value: Option<&T>) -> Edit<R>

Set or clear one cell.

Source

pub fn insert_row(&self, at: usize) -> Edit<R>

Insert a row at at (clamped) under a fresh id minted when the edit applies.

Source

pub fn insert_column(&self, at: usize) -> Edit<R>

Insert a column at at (clamped) under a fresh id.

Source

pub fn remove_row(&self, row: &Id) -> Edit<R>

Remove a row and its cells.

Source

pub fn remove_column(&self, column: &Id) -> Edit<R>

Remove a column and its cells.

Source§

impl<R, T: Model, O: Serialize + DeserializeOwned + Default + 'static> Path<R, Outbox<T, O>>

Source

pub fn settle(&self, id: &Id, outcome: &Settled<O>) -> Edit<R>

Record how the owning device settled the entry id: content from outside, nobody’s undo step.

Source

pub fn forget(&self, id: &Id) -> Edit<R>

Forget the settled entry id: housekeeping, nobody’s undo step.

Source§

impl<R> Path<R, Reactions>

Source

pub fn react(&self, emoji: impl Into<String>) -> Edit<R>

React with emoji (a Unicode emoji, or a workspace emoji as :name:), as whoever invokes the edit.

Source

pub fn unreact(&self, emoji: impl Into<String>) -> Edit<R>

Take back the invoker’s reaction with emoji.

Trait Implementations§

Source§

impl<R, T> Clone for Path<R, T>

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<R, T> Debug for Path<R, T>

Source§

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

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

impl<'de, R, T> Deserialize<'de> for Path<R, T>

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<R, T> Eq for Path<R, T>

Source§

impl<R, T> Hash for Path<R, T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<R, T> Ord for Path<R, T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<R, T> PartialEq for Path<R, T>

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<R, T> PartialOrd for Path<R, T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<R, T> Serialize for Path<R, T>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<R, T> Forget for Path<R, T>

§

impl<R, T> Freeze for Path<R, T>
where PhantomData<fn() -> (R, T)>: Freeze,

§

impl<R, T> Move for Path<R, T>

§

impl<R, T> RefUnwindSafe for Path<R, T>

§

impl<R, T> Send for Path<R, T>
where PhantomData<fn() -> (R, T)>: Send,

§

impl<R, T> Sync for Path<R, T>
where PhantomData<fn() -> (R, T)>: Sync,

§

impl<R, T> Unpin for Path<R, T>
where PhantomData<fn() -> (R, T)>: Unpin,

§

impl<R, T> UnsafeUnpin for Path<R, T>

§

impl<R, T> UnwindSafe for Path<R, T>

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more