Skip to main content

Source

Struct Source 

Source
pub struct Source { /* private fields */ }
Expand description

The last published vocabulary of one file plus one staged candidate. It reads only the path it is given and knows no default or home path.

Two equal observations are a settling heuristic: a writer paused across both can still expose an incomplete but valid file. This does not prove that an editor save completed.

Implementations§

Source§

impl Source

Source

pub fn new(parse: Parser) -> Self

An empty source whose candidates parse reads.

Source

pub fn current(&self) -> Option<Arc<Vocabulary>>

Share the last published vocabulary; None until the first publication.

Source

pub fn observe(&mut self, path: &Path) -> Result<Observation, SourceError>

Read a bounded candidate without writing the source. Call on a serialized reload path, outside input callbacks. The first valid read stages a candidate and returns Observation::Pending; a second read with equal metadata and bytes publishes it. An initial valid empty file also requires two equal observations.

§Errors

A SourceError if the file can’t be read, isn’t a regular file, exceeds the bound, changes during the read or doesn’t parse. Staging is discarded; the published snapshot stays.

Trait Implementations§

Source§

impl Default for Source

A source that parses Vim word lists.

Source§

fn default() -> Self

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