pub struct Id { /* private fields */ }Expand description
Represents some identifier in an assemble project.
Acts like a path. Consists for two parts, the this part and the parent. For example, in
root:inner:task, the this is task and the parent is root:inner.
Implementations§
Source§impl Id
impl Id
Sourcepub fn new<S: AsRef<str>>(val: S) -> Result<Self, InvalidId>
pub fn new<S: AsRef<str>>(val: S) -> Result<Self, InvalidId>
Create a new id. The leading : is optional.
§Error
Errors if it isn’t a valid identifier.
§Example
let id = Id::new("root:inner:task").unwrap();
assert!(Id::new("&task").is_err());
assert!(Id::new("2132").is_err());
assert!(Id::new("gef::as").is_err());
assert_eq!(Id::new(":root"), Id::new("root"));Sourcepub fn from_iter<S: AsRef<str>>(
iter: impl IntoIterator<Item = S>,
) -> Result<Self, InvalidId>
pub fn from_iter<S: AsRef<str>>( iter: impl IntoIterator<Item = S>, ) -> Result<Self, InvalidId>
Try to create an Id from an iterator of parts. Each part must be a valid part of an identifier.
§Example
assert!(Id::from_iter(["root", "task"]).is_ok());
assert!(Id::from_iter(["root:inner", "task"]).is_err());
assert!(Id::from_iter(["root", "inner", "task"]).is_ok());Sourcepub fn join<S: AsRef<str>>(&self, next: S) -> Result<Self, InvalidId>
pub fn join<S: AsRef<str>>(&self, next: S) -> Result<Self, InvalidId>
Joins something that can be turned into an identifier to the end of this Id.
§Error
Errors if the next is not a valid identifier
Sourcepub fn is_shorthand(&self, repr: &str) -> bool
pub fn is_shorthand(&self, repr: &str) -> bool
Check if the given representation is a valid shorthand.
pub fn is_shorthand_this(&self, repr: &str) -> bool
Sourcepub fn ancestors(&self) -> impl Iterator<Item = &Id>
pub fn ancestors(&self) -> impl Iterator<Item = &Id>
Gets the ancestors of this id.
For example, the ancestors of root:inner:task would be
root:inner:taskroot:innerroot
pub fn iter(&self) -> Iter<'_> ⓘ
pub fn as_path(&self) -> PathBuf
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Id
impl<'de> Deserialize<'de> for Id
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Id
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Freeze for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnwindSafe for Id
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
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<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
Compare self to
key and return true if they are equal.Source§impl<T> InstanceOf for T
impl<T> InstanceOf for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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