Struct ByteSet

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

An efficient, general-purpose set of u8s.

§Implementation

This is a 256-bit mask where a byte is contained based on whether its bit is enabled. The first (least significant) bit in the mask represents the first byte in the set. Likewise, the last last (most significant) bit represents the last byte.

The mask is composed a of “chunk” array. Each chunk is either 64 or 32 bits wide, depending on the target architecture. As of right now, this is based on native register size. This may change in the future based on target features that enable better performance.

Implementations§

Source§

impl ByteSet

Source

pub const fn new() -> Self

Returns a set containing no bytes.

Source

pub const fn full() -> Self

Returns a set containing all bytes (0-255).

Source

pub const fn from_byte(byte: u8) -> Self

Returns a set containing only byte.

§Examples
let byte = 42;
let set = ByteSet::from_byte(byte);

assert_eq!(set.first(), Some(byte));
assert_eq!(set.last(), Some(byte));
Source

pub const fn from_range_to(range: RangeTo<u8>) -> Self

Construct a ByteSet from a RangeTo value, i.e. ..x

Source

pub const fn from_range_to_inclusive(range: RangeToInclusive<u8>) -> Self

Construct a ByteSet from a RangeToInclusive value, i.e. ..=x

Source

pub const fn from_range_from(range: RangeFrom<u8>) -> Self

Construct a ByteSet from a RangeFrom value, i.e. x..

Source

pub const fn from_range(range: Range<u8>) -> Self

Construct a ByteSet from a RangeToInclusive value, i.e. x..y

Source

pub const fn from_range_inclusive(range: RangeInclusive<u8>) -> Self

Construct a ByteSet from a RangeInclusive value, i.e. x..=y

Source

pub fn rand<R: RngCore>(rng: R) -> Self

Available on crate features rand or rand_core only.

Returns a set containing uniformly-distributed random bytes from rng.

This uses fill_bytes under the hood.

Source

pub fn try_rand<R: RngCore>(rng: R) -> Result<Self, Error>

Available on crate features rand or rand_core only.

Returns a set containing uniformly-distributed random bytes from rng, or Err if rng failed.

This uses try_fill_bytes under the hood.

Source

pub const fn is_empty(&self) -> bool

Returns true if self contains no bytes.

This is more efficient than checking self.len() == 0.

Source

pub const fn is_full(&self) -> bool

Returns true if self contains all bytes.

This is more efficient than checking self.len() == 256.

Source

pub const fn len(&self) -> usize

Returns the number of bytes contained in self.

Source

pub fn clear(&mut self)

Removes all bytes from self.

Source

pub fn first(&self) -> Option<u8>

Returns the first (least) byte in self, or None if self is empty.

Source

pub fn pop_first(&mut self) -> Option<u8>

Removes the first (least) byte in self and returns it, or None if self is empty.

Source

pub fn last(&self) -> Option<u8>

Returns the last (greatest) byte in self, or None if self is empty.

Source

pub fn pop_last(&mut self) -> Option<u8>

Removes the last (least) byte in self and returns it, or None if self is empty.

Source

pub fn insert(&mut self, byte: u8)

Inserts byte into self in-place.

Unlike HashSet::insert and BTreeSet::insert, this does not return a bool for whether byte was not present. This is because it’s just as efficient to call contains before.

Source

pub fn insert_all(&mut self, other: Self)

Inserts all bytes of other into self in-place.

Source

pub const fn inserting(self, byte: u8) -> Self

Returns a copy of self with byte inserted.

Source

pub const fn inserting_all(self, other: Self) -> Self

Returns a copy of self with all of other inserted.

This is equivalent to the union method.

Source

pub fn remove(&mut self, byte: u8)

Removes byte from self in-place.

Unlike HashSet::remove and BTreeSet::remove, this does not return a bool for whether byte was present. This is because it’s just as efficient to call contains before.

Source

pub fn remove_all(&mut self, other: Self)

Removes all bytes of other from self in-place.

Source

pub const fn removing(self, byte: u8) -> Self

Returns a copy of self with byte removed.

Source

pub const fn removing_all(self, other: Self) -> Self

Returns a copy of self with byte removed.

Source

pub fn set(&mut self, byte: u8, enabled: bool)

Sets byte in self to enabled in-place.

Source

pub const fn setting(self, byte: u8, enabled: bool) -> Self

Returns a copy of self with byte set to enabled.

Source

pub const fn contains(&self, byte: u8) -> bool

Returns true if byte is contained in self.

Source

pub fn contains_any(&self, other: &Self) -> bool

Returns true if self contains any bytes in other.

Source

pub fn is_subset(&self, other: &Self) -> bool

Returns true if other contains all bytes in self.

Source

pub fn is_strict_subset(&self, other: &Self) -> bool

Returns true if other contains all bytes in self and at least one other byte not contained in self.

This is also known as a “proper subset”.

Source

pub fn is_superset(&self, other: &Self) -> bool

Returns true if self contains all bytes in other.

Source

pub fn is_strict_superset(&self, other: &Self) -> bool

Returns true if self contains all bytes in other and at least one other byte not contained in other.

This is also known as a “proper superset”.

Source

pub fn is_disjoint(&self, other: &Self) -> bool

Returns true if self and other have no bytes in common.

Source

pub const fn difference(self, other: Self) -> Self

Returns a set with the bytes contained in self, but not in other.

Source

pub const fn symmetric_difference(self, other: Self) -> Self

Returns a set with the bytes contained in self or other, but not in both.

Source

pub const fn intersection(self, other: Self) -> Self

Returns a set with the bytes contained both in self and other.

Source

pub const fn union(self, other: Self) -> Self

Returns a new set with the bytes contained in self or other.

Source

pub const fn not(self) -> Self

Returns a new set with the bytes not contained in self.

This exists because the Not trait cannot be used in const yet.

Source

pub const fn reverse_bits(self) -> Self

Returns self with its bits reversed.

This is equivalent to checking for 255 - b in all subsequent searches of b.

Source

pub const fn eq(&self, other: &Self) -> bool

Returns true if self and other contain the same bytes.

This exists because PartialEq is currently unstable in const.

Source

pub const fn ne(&self, other: &Self) -> bool

Returns true if self and other do not contain the same bytes.

This exists because PartialEq is currently unstable in const.

Source§

impl ByteSet

Operations related to the ASCII character set.

Source

pub const ASCII: Self

The set of all ASCII characters: U+0000 NULL ..= U+007F DELETE.

§Examples

This contains all bytes for which u8::is_ascii returns true:

for byte in ByteSet::ASCII {
    assert!(byte.is_ascii());
}

for byte in !ByteSet::ASCII {
    assert!(!byte.is_ascii());
}
Source

pub const ASCII_ALPHABETIC: Self

The set of all ASCII alphabetic characters:

  • U+0041 ‘A’ ..= U+005A ‘Z’
  • U+0061 ‘a’ ..= U+007A ‘z’
§Examples

This contains all bytes for which u8::is_ascii_alphabetic returns true:

for byte in ByteSet::ASCII_ALPHABETIC {
    assert!(byte.is_ascii_alphabetic());
}

for byte in !ByteSet::ASCII_ALPHABETIC {
    assert!(!byte.is_ascii_alphabetic());
}
Source

pub const ASCII_UPPERCASE: Self

The set of all ASCII uppercase characters: U+0041 ‘A’ ..= U+005A ‘Z’.

§Examples

This contains all bytes for which u8::is_ascii_uppercase returns true:

for byte in ByteSet::ASCII_UPPERCASE {
    assert!(byte.is_ascii_uppercase());
}

for byte in !ByteSet::ASCII_UPPERCASE {
    assert!(!byte.is_ascii_uppercase());
}
Source

pub const ASCII_LOWERCASE: Self

The set of all ASCII lowercase characters: U+0061 ‘a’ ..= U+007A ‘z’.

§Examples

This contains all bytes for which u8::is_ascii_lowercase returns true:

for byte in ByteSet::ASCII_LOWERCASE {
    assert!(byte.is_ascii_lowercase());
}

for byte in !ByteSet::ASCII_LOWERCASE {
    assert!(!byte.is_ascii_lowercase());
}
Source

pub const ASCII_ALPHANUMERIC: Self

The set of all ASCII alphanumeric characters:

  • U+0041 ‘A’ ..= U+005A ‘Z’
  • U+0061 ‘a’ ..= U+007A ‘z’
  • U+0030 ‘0’ ..= U+0039 ‘9’
§Examples

This contains all bytes for which u8::is_ascii_alphanumeric returns true:

for byte in ByteSet::ASCII_ALPHANUMERIC {
    assert!(byte.is_ascii_alphanumeric());
}

for byte in !ByteSet::ASCII_ALPHANUMERIC {
    assert!(!byte.is_ascii_alphanumeric());
}
Source

pub const ASCII_DIGIT: Self

The set of all ASCII decimal digits: U+0030 ‘0’ ..= U+0039 ‘9’.

§Examples

This contains all bytes for which u8::is_ascii_digit returns true:

for byte in ByteSet::ASCII_DIGIT {
    assert!(byte.is_ascii_digit());
}

for byte in !ByteSet::ASCII_DIGIT {
    assert!(!byte.is_ascii_digit());
}
Source

pub const ASCII_HEXDIGIT: Self

The set of all ASCII hexadecimal digits:

  • U+0030 ‘0’ ..= U+0039 ‘9’
  • U+0041 ‘A’ ..= U+0046 ‘F’
  • U+0061 ‘a’ ..= U+0066 ‘f’
§Examples

This contains all bytes for which u8::is_ascii_hexdigit returns true:

for byte in ByteSet::ASCII_HEXDIGIT {
    assert!(byte.is_ascii_hexdigit());
}

for byte in !ByteSet::ASCII_HEXDIGIT {
    assert!(!byte.is_ascii_hexdigit());
}
Source

pub const ASCII_PUNCTUATION: Self

The set of all ASCII punctuation characters:

  • U+0021 ..= U+002F ! " # $ % & ' ( ) * + , - . /
  • U+003A ..= U+0040 : ; < = > ? @
  • U+005B ..= U+0060 [ \ ] ^ _ `
  • U+007B ..= U+007E { | } ~
§Examples

This contains all bytes for which u8::is_ascii_punctuation returns true:

for byte in ByteSet::ASCII_PUNCTUATION {
    assert!(byte.is_ascii_punctuation());
}

for byte in !ByteSet::ASCII_PUNCTUATION {
    assert!(!byte.is_ascii_punctuation());
}
Source

pub const ASCII_GRAPHIC: Self

The set of all ASCII graphic characters: U+0021 ‘!’ ..= U+007E ‘~’.

§Examples

This contains all bytes for which u8::is_ascii_graphic returns true:

for byte in ByteSet::ASCII_GRAPHIC {
    assert!(byte.is_ascii_graphic());
}

for byte in !ByteSet::ASCII_GRAPHIC {
    assert!(!byte.is_ascii_graphic());
}
Source

pub const ASCII_WHITESPACE: Self

The set of all ASCII whitespace characters:

  • U+0020 SPACE
  • U+0009 HORIZONTAL TAB
  • U+000A LINE FEED
  • U+000C FORM FEED
  • U+000D CARRIAGE RETURN
§Examples

This contains all bytes for which u8::is_ascii_whitespace returns true:

for byte in ByteSet::ASCII_WHITESPACE {
    assert!(byte.is_ascii_whitespace());
}

for byte in !ByteSet::ASCII_WHITESPACE {
    assert!(!byte.is_ascii_whitespace());
}
Source

pub const ASCII_CONTROL: Self

The set of all ASCII control characters:

  • U+0000 NUL ..= U+001F UNIT SEPARATOR
  • U+007F DELETE.

Note that most ASCII whitespace characters are control characters, but SPACE is not.

§Examples

This contains all bytes for which u8::is_ascii_control returns true:

for byte in ByteSet::ASCII_CONTROL {
    assert!(byte.is_ascii_control());
}

for byte in !ByteSet::ASCII_CONTROL {
    assert!(!byte.is_ascii_control());
}
Source

pub const fn is_ascii(&self) -> bool

Returns true if u8::is_ascii returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_alphabetic(&self) -> bool

Returns true if u8::is_ascii_alphabetic returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_uppercase(&self) -> bool

Returns true if u8::is_ascii_uppercase returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_lowercase(&self) -> bool

Returns true if u8::is_ascii_lowercase returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_alphanumeric(&self) -> bool

Returns true if u8::is_ascii_alphanumeric returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_digit(&self) -> bool

Returns true if u8::is_ascii_digit returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_hexdigit(&self) -> bool

Returns true if u8::is_ascii_hexdigit returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_punctuation(&self) -> bool

Returns true if u8::is_ascii_punctuation returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_graphic(&self) -> bool

Returns true if u8::is_ascii_graphic returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_whitespace(&self) -> bool

Returns true if u8::is_ascii_whitespace returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source

pub const fn is_ascii_control(&self) -> bool

Returns true if u8::is_ascii_control returns true for all bytes in self.

This is significantly more efficient than checking each byte in self individually.

Source§

impl ByteSet

Operations over the internal memory representation.

There are currently no stability guarantees over the internal bytes. This is being tracked in #8.

Source

pub fn as_bytes(&self) -> &[u8; 32]

Returns a shared reference to the underlying bytes of self.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8; 32]

Returns a mutable reference to the underlying bytes of self.

Source

pub fn slice_as_bytes(slice: &[Self]) -> &[u8]

Returns a shared reference to the underlying bytes of slice.

Source

pub fn slice_as_bytes_mut(slice: &mut [Self]) -> &mut [u8]

Returns a mutable reference to the underlying bytes of slice.

Trait Implementations§

Source§

impl BitAnd for ByteSet

Source§

type Output = ByteSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for ByteSet

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for ByteSet

Source§

type Output = ByteSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for ByteSet

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for ByteSet

Source§

type Output = ByteSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for ByteSet

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for ByteSet

Source§

fn clone(&self) -> ByteSet

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 ByteSet

Source§

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

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

impl Default for ByteSet

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ByteSet

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Distribution<ByteSet> for Standard

Available on crate feature rand only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> ByteSet

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

impl<'a> Extend<&'a u8> for ByteSet

Source§

fn extend<T: IntoIterator<Item = &'a u8>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

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 Extend<u8> for ByteSet

Source§

fn extend<T: IntoIterator<Item = u8>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

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 From<&[u8]> for ByteSet

Source§

fn from(bytes: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for ByteSet

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<ByteSet> for Iter

Source§

fn from(byte_set: ByteSet) -> Self

Converts to this type from the input type.
Source§

impl From<Range<u8>> for ByteSet

Source§

fn from(range: Range<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeFrom<u8>> for ByteSet

Source§

fn from(range: RangeFrom<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeFull> for ByteSet

Source§

fn from(_: RangeFull) -> Self

Converts to this type from the input type.
Source§

impl From<RangeInclusive<u8>> for ByteSet

Source§

fn from(range: RangeInclusive<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeTo<u8>> for ByteSet

Source§

fn from(range: RangeTo<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<RangeToInclusive<u8>> for ByteSet

Source§

fn from(range: RangeToInclusive<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for ByteSet

Source§

fn from(byte: u8) -> ByteSet

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a u8> for ByteSet

Source§

fn from_iter<T: IntoIterator<Item = &'a u8>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<u8> for ByteSet

Source§

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

Creates a value from an iterator. Read more
Source§

impl Hash for ByteSet

Source§

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

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

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

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

impl IntoIterator for ByteSet

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = Iter

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 Not for ByteSet

Source§

type Output = ByteSet

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for ByteSet

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ByteSet

Source§

fn eq(&self, other: &ByteSet) -> 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 PartialOrd for ByteSet

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &Self) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &Self) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &Self) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &Self) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for ByteSet

Available on crate feature serde only.
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 Sub for ByteSet

Source§

type Output = ByteSet

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for ByteSet

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for ByteSet

Source§

impl Eq for ByteSet

Source§

impl StructuralPartialEq for ByteSet

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,