Skip to main content

Path

Struct Path 

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

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

Implementations§

§

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

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

The item id, its own paths rooted here.

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

The path of the item id itself.

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

Remove the item id.

§

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

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.

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

Add item under its own id.

§

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

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

Add item under its own id at position at.

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

Move the item id to position at.

§

impl<R> Path<R, R>

pub const fn root() -> Path<R, R>

The record itself.

§

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

pub fn object(&self, doc: &AutoCommit) -> Option<ExId>

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.

§

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

pub fn from_segments(segments: Vec<Segment>) -> Path<R, T>

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

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

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

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.

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.

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

Whether self is other or lies inside it.

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

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

The edit op at this path.

§

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

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

Replace the value.

§

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

pub fn perform(&self, op: &<T as Operations>::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.

§

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

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

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

§

impl<R> Path<R, String>

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

Replace delete characters at at with insert.

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.

§

impl<R> Path<R, Counter>

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

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

§

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

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

Add an element.

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

Remove an element.

§

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

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

The item id, its own paths rooted here.

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

The path of the item id itself.

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.

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

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

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

Remove the item id.

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

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

§

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

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

The entry key, its own paths rooted here.

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

Remove the entry key.

§

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

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

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

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

Set or clear one cell.

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

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

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

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

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

Remove a row and its cells.

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

Remove a column and its cells.

§

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

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.

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

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

Trait Implementations§

§

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

§

fn clone(&self) -> Path<R, T>

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
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

fn deserialize<D>( deserializer: D, ) -> Result<Path<R, T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

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

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

§

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

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
§

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

§

fn cmp(&self, other: &Path<R, T>) -> 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
§

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

§

fn eq(&self, other: &Path<R, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

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

§

fn partial_cmp(&self, other: &Path<R, T>) -> 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
§

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

§

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

Serialize this value into the given Serde serializer. Read more
§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,