Skip to main content

WriteEnvironment

Struct WriteEnvironment 

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

The write environment: FLM’s part of what a writing session needs. It records, for every element value that a registered specification carries, which specification that is.

A node extension writes a reference to that specification beside the element’s name, so the element reads back as the exact value even when several values share one name (see the module documentation). Without this environment, a node extension writes the name alone, and the reading side’s element resolver decides.

Build a language’s environment with WriteEnvironment::for_lang, and set it as the session’s user data; crate::dump::session::writer does both. Its public path is crate::dump::session::WriteEnvironment.

Implementations§

Source§

impl WriteEnvironment

Source

pub fn new() -> WriteEnvironment

Returns an environment that records no element yet.

Source

pub fn for_lang(lang: &BuiltLang) -> WriteEnvironment

Returns the environment of a writing session over lang. It records the specifications of every provider of the language, those of its initial parsing state followed by BuiltLang::providers, as for_providers does, and leaves out the structural elements (BuiltLang::structural): a node carrying one is written with the element’s name alone, which the reading side resolves to its own structural element of that name.

Of the structural elements, only the field element (StructuralElements::field) is carried by specifications that a provider lists: the specification of every tack-on field carries it, so none of them identifies it better than its name.

Source

pub fn for_providers<'a>( providers: impl IntoIterator<Item = &'a Arc<dyn SpecsProvider<Flm>>>, ) -> WriteEnvironment

Returns the environment built by asking each of providers for the names it registers. A provider that cannot list its names, such as the fallback provider, adds nothing.

The result depends only on the input: the providers are taken from the last to the first, and within each, callable forms and parsing modes in their fixed order and names in sorted order. Where specifications of several providers carry one element, the one of the provider latest in the list is recorded: the features’ packages are listed in registration order, so between features, the specification of the feature placed last. Within one provider, the first one found is recorded.

Every element that a specification carries is recorded, a structural element included; for_lang builds the environment of a language, without its structural elements.

Source

pub fn index_provider(&mut self, provider: &dyn SpecsProvider<Flm>)

Records, for every element that a specification of provider carries and that is not recorded yet, that specification.

Source

pub fn index_spec(&mut self, spec: Arc<dyn CallableSpec<Flm>>)

Records spec for the element it carries, unless that element is recorded already. A specification carrying no element is ignored.

Source

pub fn spec_of( &self, element: &Arc<ElementSpec>, ) -> Option<&Arc<dyn CallableSpec<Flm>>>

Returns the specification recorded for element, if there is one.

Source

pub fn len(&self) -> usize

Returns how many elements have a recorded specification.

Source

pub fn is_empty(&self) -> bool

Returns whether no element has a recorded specification.

Trait Implementations§

Source§

impl Debug for WriteEnvironment

Source§

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

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

impl Default for WriteEnvironment

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for WriteEnvironment

§

impl !UnwindSafe for WriteEnvironment

§

impl Forget for WriteEnvironment

§

impl Freeze for WriteEnvironment
where *const LeafNode<usize, Arc<dyn CallableSpec<Flm>>> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(usize, Arc<dyn CallableSpec<Flm>>)>>: Freeze,

§

impl Move for WriteEnvironment

§

impl Send for WriteEnvironment
where NodeRef<Owned, usize, Arc<dyn CallableSpec<Flm>>, LeafOrInternal>: Send, BoxRaw<(usize, Arc<dyn CallableSpec<Flm>>)>: Send,

§

impl Sync for WriteEnvironment
where NodeRef<Owned, usize, Arc<dyn CallableSpec<Flm>>, LeafOrInternal>: Sync, BoxRaw<(usize, Arc<dyn CallableSpec<Flm>>)>: Sync,

§

impl Unpin for WriteEnvironment
where *const LeafNode<usize, Arc<dyn CallableSpec<Flm>>> is !null: Unpin, Box<(usize, Arc<dyn CallableSpec<Flm>>)>: Unpin,

§

impl UnsafeUnpin for WriteEnvironment
where *const LeafNode<usize, Arc<dyn CallableSpec<Flm>>> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(usize, Arc<dyn CallableSpec<Flm>>)>>: UnsafeUnpin,

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> 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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.