Skip to main content

ContentCache

Struct ContentCache 

Source
pub struct ContentCache<L: Language + Send + Sync + 'static> { /* private fields */ }
Expand description

A content-based cache for parsed results.

This cache stores parsed results based on the hash of the source content, allowing for efficient reuse of parsing results when processing the same content multiple times.

Implementations§

Source§

impl<L: Language + Send + Sync + 'static> ContentCache<L>

Source

pub fn new(max_entries: usize) -> Self

Creates a new content cache with the specified maximum size.

Source

pub fn get<S: Source + ?Sized>( &self, source: &S, ) -> Option<(&GreenNode<'_, L>, &LexOutput<L>)>

Gets a cached entry for the given source content if it exists.

Source

pub fn insert<S: Source + ?Sized>( &mut self, source: &S, root: &GreenNode<'_, L>, lex_output: LexOutput<L>, )

Inserts a new entry into the cache.

Source

pub fn clear(&mut self)

Clears all entries from the cache.

Source

pub fn len(&self) -> usize

Returns the current number of entries in the cache.

Source

pub fn is_empty(&self) -> bool

Returns true if the cache is empty.

Trait Implementations§

Source§

impl<L: Language + Send + Sync + 'static> Default for ContentCache<L>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<L> Freeze for ContentCache<L>

§

impl<L> !RefUnwindSafe for ContentCache<L>

§

impl<L> Send for ContentCache<L>

§

impl<L> Sync for ContentCache<L>

§

impl<L> Unpin for ContentCache<L>

§

impl<L> UnsafeUnpin for ContentCache<L>

§

impl<L> !UnwindSafe for ContentCache<L>

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

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

Source§

fn vzip(self) -> V