pub struct ModulePath {
pub head: PathHead,
pub segments: Vec<Name>,
/* private fields */
}Expand description
The nouns of the plugin contract that appear in the engine’s answers, so an interface needs nothing but this crate. A path as spelled in source: its head and its segments, with the syntax that spells it. Serialises as the text, so the wire is what the user wrote.
Fields§
§head: PathHead§segments: Vec<Name>Implementations§
Source§impl ModulePath
impl ModulePath
pub fn new( syntax: PathSyntax, head: PathHead, segments: impl IntoIterator<Item = impl Into<Name>>, ) -> ModulePath
pub fn syntax(&self) -> PathSyntax
pub fn first(&self) -> Option<&Name>
pub fn last(&self) -> Option<&Name>
pub fn is_empty(&self) -> bool
Sourcepub fn strip_prefix(&self, prefix: &ModulePath) -> Option<&[Name]>
pub fn strip_prefix(&self, prefix: &ModulePath) -> Option<&[Name]>
The segments after prefix, when this path continues it: same head,
its segments first.
Sourcepub fn continues(&self, prefix: &ModulePath) -> bool
pub fn continues(&self, prefix: &ModulePath) -> bool
Whether this path continues prefix by at least one segment.
Sourcepub fn with_segments(
&self,
segments: impl IntoIterator<Item = impl Into<Name>>,
) -> ModulePath
pub fn with_segments( &self, segments: impl IntoIterator<Item = impl Into<Name>>, ) -> ModulePath
The same path with segments in place of its own.
Sourcepub fn prefix(&self, index: usize) -> ModulePath
pub fn prefix(&self, index: usize) -> ModulePath
The path up to and including segment index: what a token in the
middle of a path names.
Sourcepub fn segment_at(&self, offset: usize) -> Option<usize>
pub fn segment_at(&self, offset: usize) -> Option<usize>
Which segment is spelled at byte offset from the path’s start, as
its syntax writes it; None on a separator or the head.
Sourcepub fn spell_segments(&self, segments: &[Name]) -> String
pub fn spell_segments(&self, segments: &[Name]) -> String
segments alone, spelled in this path’s syntax: the tail after a
group’s prefix.
Trait Implementations§
Source§impl Clone for ModulePath
impl Clone for ModulePath
Source§fn clone(&self) -> ModulePath
fn clone(&self) -> ModulePath
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModulePath
impl Debug for ModulePath
Source§impl<'de> Deserialize<'de> for ModulePath
A path read back from text carries no syntax; :: anywhere means
scoped, anything else Posix.
impl<'de> Deserialize<'de> for ModulePath
A path read back from text carries no syntax; :: anywhere means
scoped, anything else Posix.
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ModulePath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ModulePath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for ModulePath
impl Display for ModulePath
impl Eq for ModulePath
Source§impl Hash for ModulePath
impl Hash for ModulePath
Source§impl Ord for ModulePath
impl Ord for ModulePath
Source§fn cmp(&self, other: &ModulePath) -> Ordering
fn cmp(&self, other: &ModulePath) -> Ordering
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 PartialEq for ModulePath
impl PartialEq for ModulePath
Source§impl PartialOrd for ModulePath
impl PartialOrd for ModulePath
Source§impl Serialize for ModulePath
impl Serialize for ModulePath
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for ModulePath
Auto Trait Implementations§
impl Freeze for ModulePath
impl RefUnwindSafe for ModulePath
impl Send for ModulePath
impl Sync for ModulePath
impl Unpin for ModulePath
impl UnsafeUnpin for ModulePath
impl UnwindSafe for ModulePath
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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