pub struct FlmOrigin { /* private fields */ }Expand description
Where an FLM source comes from: its canonical path when it has one, or the label of a source the library created.
Create an origin with FlmOrigin::new for a file, FlmOrigin::none
for an unnamed snippet, FlmOrigin::synthetic or
FlmOrigin::definition for a source the library creates, and attach it to
a source with FlmSource::with_origin. The module documentation
explains what the canonical path is used for.
§Examples
use flm_core::lang::FlmOrigin;
use flm_core::techy::source::SourceOrigin;
let file = FlmOrigin::new("book/ch1.flm");
assert_eq!(file.canonical_path(), Some("book/ch1.flm"));
assert_eq!(file.label().as_deref(), Some("book/ch1.flm"));
// A source the library creates has a label but no path, so no check keyed
// by source applies to it.
let made = FlmOrigin::synthetic("expansion of \\foo");
assert_eq!(made.canonical_path(), None);
assert_eq!(made.label().as_deref(), Some("expansion of \\foo"));
// An unnamed snippet has neither.
assert_eq!(FlmOrigin::none(), FlmOrigin::default());
assert_eq!(FlmOrigin::none().label(), None);Implementations§
Source§impl FlmOrigin
impl FlmOrigin
Sourcepub fn new(canonical_path: impl Into<String>) -> FlmOrigin
pub fn new(canonical_path: impl Into<String>) -> FlmOrigin
Returns an origin whose canonical path is canonical_path.
Sourcepub fn none() -> FlmOrigin
pub fn none() -> FlmOrigin
Returns the origin of a source with no name at all. This is also the
Default.
Sourcepub fn synthetic(label: impl Into<String>) -> FlmOrigin
pub fn synthetic(label: impl Into<String>) -> FlmOrigin
Returns the origin of a source the library creates: no canonical path,
so no check keyed by source applies to it, and label as the name that
diagnostics show.
Sourcepub fn definition(label: impl Into<String>) -> FlmOrigin
pub fn definition(label: impl Into<String>) -> FlmOrigin
Returns the origin of the source a user definition’s own text is
compiled from (its template, or the default value of one of its
arguments): a synthetic origin labeled label,
marked as a user definition’s own text
(is_definition).
Sourcepub fn is_definition(&self) -> bool
pub fn is_definition(&self) -> bool
Returns whether this is the origin of a user definition’s own text (its
template or an argument’s default value), created with
FlmOrigin::definition.
The parser of \input reads it: an \input written in such text
includes no file and is reported
(InputInDefinition).
Sourcepub fn canonical_path(&self) -> Option<&str>
pub fn canonical_path(&self) -> Option<&str>
Returns the canonical path, when there is one. It is the key of every check and table keyed by source.
Sourcepub fn synthetic_label(&self) -> Option<&str>
pub fn synthetic_label(&self) -> Option<&str>
Returns the label of a source the library created, when there is one.
The label a diagnostic shows is SourceOrigin::label, which prefers
the canonical path.
Trait Implementations§
Source§impl<__L: Lang> DeserializableValue<__L> for FlmOrigin
impl<__L: Lang> DeserializableValue<__L> for FlmOrigin
Source§fn deserialize_value(
__value: &SerialValue,
__cx: &mut DeserializeContext<'_, __L>,
) -> Result<Self, DeserializeError>where
__L: SerializableLang,
fn deserialize_value(
__value: &SerialValue,
__cx: &mut DeserializeContext<'_, __L>,
) -> Result<Self, DeserializeError>where
__L: SerializableLang,
cx gives the call access to the
state of the deserialization in progress. Read moreSource§fn deserialize_field(
name: &'static str,
value: Option<&SerialValue>,
cx: &mut DeserializeContext<'_, L>,
) -> Result<Self, DeserializeError>where
L: SerializableLang,
fn deserialize_field(
name: &'static str,
value: Option<&SerialValue>,
cx: &mut DeserializeContext<'_, L>,
) -> Result<Self, DeserializeError>where
L: SerializableLang,
name of a structure whose fields are read by
name (a type with #[derive(DeserializableValue)]): value is the field’s
value, or None when the key is missing from the map. The default requires
the key and reads its value with deserialize_value;
Option<T> reads a missing key as None. The counterpart of
SerializableValue::is_absent_field: a type overriding one overrides both. Read moreimpl Eq for FlmOrigin
Source§impl Ord for FlmOrigin
impl Ord for FlmOrigin
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for FlmOrigin
impl PartialOrd for FlmOrigin
Source§impl<__L: Lang> SerializableValue<__L> for FlmOrigin
impl<__L: Lang> SerializableValue<__L> for FlmOrigin
Source§fn serialize_value(
&self,
__cx: &mut SerializeContext<'_, __L>,
) -> Result<SerialValue, SerializeError>where
__L: SerializableLang,
fn serialize_value(
&self,
__cx: &mut SerializeContext<'_, __L>,
) -> Result<SerialValue, SerializeError>where
__L: SerializableLang,
cx gives the call access to the state
of the serialization in progress — a value that refers to a table object
(a span’s source, say) interns it through cx and embeds the position. Read moreSource§fn is_absent_field(&self) -> boolwhere
L: SerializableLang,
fn is_absent_field(&self) -> boolwhere
L: SerializableLang,
#[derive(SerializableValue)]), is left out of the structure’s map
entirely — no key at all, rather than a key with a null value. The default is
false; Option<T> is absent when it is None. Read moreSource§impl SourceOrigin for FlmOrigin
impl SourceOrigin for FlmOrigin
impl StructuralPartialEq for FlmOrigin
Auto Trait Implementations§
impl Forget for FlmOrigin
impl Freeze for FlmOrigin
impl Move for FlmOrigin
impl RefUnwindSafe for FlmOrigin
impl Send for FlmOriginwhere
RawVecInner: Send,
impl Sync for FlmOriginwhere
RawVecInner: Sync,
impl Unpin for FlmOrigin
impl UnsafeUnpin for FlmOrigin
impl UnwindSafe for FlmOriginwhere
RawVecInner: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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