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
impl WriteEnvironment
Sourcepub fn new() -> WriteEnvironment
pub fn new() -> WriteEnvironment
Returns an environment that records no element yet.
Sourcepub fn for_lang(lang: &BuiltLang) -> WriteEnvironment
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.
Sourcepub fn for_providers<'a>(
providers: impl IntoIterator<Item = &'a Arc<dyn SpecsProvider<Flm>>>,
) -> WriteEnvironment
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.
Sourcepub fn index_provider(&mut self, provider: &dyn SpecsProvider<Flm>)
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.
Sourcepub fn index_spec(&mut self, spec: Arc<dyn CallableSpec<Flm>>)
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.
Sourcepub fn spec_of(
&self,
element: &Arc<ElementSpec>,
) -> Option<&Arc<dyn CallableSpec<Flm>>>
pub fn spec_of( &self, element: &Arc<ElementSpec>, ) -> Option<&Arc<dyn CallableSpec<Flm>>>
Returns the specification recorded for element, if there is one.
Trait Implementations§
Source§impl Debug for WriteEnvironment
impl Debug for WriteEnvironment
Auto Trait Implementations§
impl !RefUnwindSafe for WriteEnvironment
impl !UnwindSafe for WriteEnvironment
impl Forget for WriteEnvironment
impl Freeze for WriteEnvironmentwhere
*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 WriteEnvironmentwhere
NodeRef<Owned, usize, Arc<dyn CallableSpec<Flm>>, LeafOrInternal>: Send,
BoxRaw<(usize, Arc<dyn CallableSpec<Flm>>)>: Send,
impl Sync for WriteEnvironmentwhere
NodeRef<Owned, usize, Arc<dyn CallableSpec<Flm>>, LeafOrInternal>: Sync,
BoxRaw<(usize, Arc<dyn CallableSpec<Flm>>)>: Sync,
impl Unpin for WriteEnvironment
impl UnsafeUnpin for WriteEnvironmentwhere
*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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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