Skip to main content

DocumentSnapshot

Struct DocumentSnapshot 

Source
pub struct DocumentSnapshot {
    pub id: DocumentId,
    pub version: u64,
    pub text_version: u64,
    pub buffer: Buffer,
    pub path: Option<Arc<PathBuf>>,
    pub dirty: bool,
    pub selections: Arc<SelectionSet>,
}
Expand description

One immutable snapshot of a document. Cheap to clone (every non-trivial field is already Arc-shareable internally; Buffer wraps a ropey::Rope whose interior is a B-tree of Arcs, so cloning is O(log n) with no heap allocation in the common case).

Fields§

§id: DocumentId§version: u64

Bumps on any commit (edits, undo, redo, set_path, mark_clean).

§text_version: u64

Bumps only on text-mutating commits. Used by the syntax cache to decide whether to reparse.

§buffer: Buffer§path: Option<Arc<PathBuf>>

Arc<PathBuf> so cloning a snapshot doesn’t clone the path string. None means an unsaved buffer (*scratch*-style).

§dirty: bool

True iff the buffer differs from its on-disk state. Tracked by the document’s clean-position bookkeeping; the snapshot just reflects the current value.

§selections: Arc<SelectionSet>

Arc<SelectionSet> so cloning a snapshot doesn’t clone the selection vector. v1 single-cursor: this is always one charwise selection; multi-cursor support folds in here when it lands.

Implementations§

Source§

impl DocumentSnapshot

Source

pub fn path(&self) -> Option<&Path>

Convenience: borrow the path slice if set.

Source

pub fn text(&self) -> String

Convenience: render the buffer to a String. The renderer’s hot path should prefer [Buffer::as_string] on &self.buffer directly; this is for tests / debug output.

Trait Implementations§

Source§

impl Clone for DocumentSnapshot

Source§

fn clone(&self) -> DocumentSnapshot

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 DocumentSnapshot

Source§

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

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

impl Default for DocumentSnapshot

Source§

fn default() -> DocumentSnapshot

Returns the “default value” for a type. Read more

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.

§

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