SharedTagSet

Struct SharedTagSet 

Source
pub struct SharedTagSet(/* private fields */);
Expand description

A shared, read-only set of tags.

§Structural sharing

In many cases, it is useful to extend a set of tags with additional tags, without needing to clone the additional tags or re-allocate the underlying storage to fit the entire set of tags. SharedTagSet supports this by utilizing “structural sharing”, where SharedTagSet is internally represented by a set of smart pointers to TagSet.

This allows SharedTagSet to be cheaply extended with additional SharedTagSet instances, without needing to allocate enough underlying storage to hold all of the individual tags. Extending a SharedTagSet will allocate a small amount of memory (8 bytes) for each additional SharedTagSet that is chained after the first additional one: this means that all new SharedTagSet instances can be extended once with no allocations whatsoever.

Implementations§

Source§

impl SharedTagSet

Source

pub fn is_empty(&self) -> bool

Returns true if the tag set is empty.

Source

pub fn len(&self) -> usize

Returns the number of tags in the set.

Source

pub fn has_tag<T>(&self, tag: T) -> bool
where T: AsRef<str>,

Returns true if the given tag is contained in the set.

This matches the complete tag, rather than just the name.

Source

pub fn get_single_tag<T>(&self, tag_name: T) -> Option<&Tag>
where T: AsRef<str>,

Gets a single tag, by name, from the set.

If multiple tags are present with the same name, the first tag with a matching name will be returned. If no tag in the set matches, None is returned.

Source

pub fn extend_from_shared(&mut self, other: &SharedTagSet)

Extends self with the tags from the other.

If any of the individual TagSet instances in other are already present in self, they will not be added again. This method does not avoid duplicates across different SharedTagSet instances, so if the same tag is present in both self and other, it will be present when querying the resulting SharedTagSet.

Source

pub fn as_tag_sets(&self) -> &[Arc<TagSet>]

Returns a reference to the underlying TagSet instances.

Source

pub fn size_of(&self) -> usize

Returns the size of the tag set, in bytes.

This includes the size of the vector holding any chained tagsets as well as each individual tag.

Additionally, the value returned by this method does not compensate for externalities such as whether or not tags are are inlined, interned, or heap allocated. This means that the value returned is essentially the worst-case usage, and should be used as a rough estimate.

Trait Implementations§

Source§

impl Clone for SharedTagSet

Source§

fn clone(&self) -> SharedTagSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharedTagSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SharedTagSet

Source§

fn default() -> SharedTagSet

Returns the “default value” for a type. Read more
Source§

impl Display for SharedTagSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<TagSet> for SharedTagSet

Source§

fn from(tag_set: TagSet) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Tag> for SharedTagSet

Source§

fn from_iter<T: IntoIterator<Item = Tag>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for SharedTagSet

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a SharedTagSet

Source§

type Item = &'a Tag

The type of the elements being iterated over.
Source§

type IntoIter = SharedTagSetIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq<TagSet> for SharedTagSet

Source§

fn eq(&self, other: &TagSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for SharedTagSet

Source§

fn eq(&self, other: &SharedTagSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SharedTagSet

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for SharedTagSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Stringable for T
where T: Display,

§

fn to_shared_string(&self) -> Cow<'static, str>

Converts the given value to a SharedString.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> Track for T

§

fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>

Instruments this type by attaching the given allocation group token, returning a Tracked wrapper. Read more
§

fn in_current_allocation_group(self) -> Tracked<Self>

Instruments this type by attaching the current allocation group, returning a Tracked wrapper. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more