pub struct Tag(/* private fields */);Expand description
One identify tag, such as python, text or executable.
A Tag is a 2-byte handle: its id is the tag’s position in
the sorted ALL_TAGS array, so comparing tags compares their names.
Only the eight file-system tags have named constants (Tag::FILE,
Tag::TEXT, …); look any other tag up by name:
use file_identify::Tag;
let python: Tag = "python".parse()?;
assert_eq!(python.as_str(), "python");
assert_eq!(Tag::from_name("python"), Some(python));
assert_eq!(Tag::from_name("pythn"), None);
assert!(Tag::FILE < Tag::TEXT); // name orderImplementations§
Source§impl Tag
impl Tag
Sourcepub const EXECUTABLE: Tag
pub const EXECUTABLE: Tag
executable: file mode tag (identify.MODE_TAGS).
Sourcepub const NON_EXECUTABLE: Tag
pub const NON_EXECUTABLE: Tag
non-executable: file mode tag (identify.MODE_TAGS).
Source§impl Tag
impl Tag
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Look a tag up by its exact (case-sensitive) name.
This is a hash lookup with no allocation.
Sourcepub const fn is_type_tag(self) -> bool
pub const fn is_type_tag(self) -> bool
Whether this is one of TYPE_TAGS.
Sourcepub const fn is_mode_tag(self) -> bool
pub const fn is_mode_tag(self) -> bool
Whether this is one of MODE_TAGS.
Sourcepub const fn is_encoding_tag(self) -> bool
pub const fn is_encoding_tag(self) -> bool
Whether this is one of ENCODING_TAGS.
Trait Implementations§
Source§impl BitAndAssign<Tag> for TagSet
impl BitAndAssign<Tag> for TagSet
Source§fn bitand_assign(&mut self, rhs: Tag)
fn bitand_assign(&mut self, rhs: Tag)
Performs the
&= operation. Read moreSource§impl BitOrAssign<Tag> for TagSet
impl BitOrAssign<Tag> for TagSet
Source§fn bitor_assign(&mut self, rhs: Tag)
fn bitor_assign(&mut self, rhs: Tag)
Performs the
|= operation. Read moreSource§impl BitXorAssign<Tag> for TagSet
impl BitXorAssign<Tag> for TagSet
Source§fn bitxor_assign(&mut self, rhs: Tag)
fn bitxor_assign(&mut self, rhs: Tag)
Performs the
^= operation. Read moreimpl Copy for Tag
impl Eq for Tag
Source§impl Extend<Tag> for TagSet
impl Extend<Tag> for TagSet
Source§fn extend<I: IntoIterator<Item = Tag>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Tag>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl FromIterator<Tag> for TagSet
impl FromIterator<Tag> for TagSet
Source§impl Ord for Tag
impl Ord for Tag
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Tag
impl PartialOrd for Tag
impl StructuralPartialEq for Tag
Auto Trait Implementations§
impl Freeze for Tag
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnsafeUnpin for Tag
impl UnwindSafe for Tag
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