Struct TinyId

Source
pub struct TinyId { /* private fields */ }
Expand description

A tiny 8-byte ID type that is NOT cryptographically secure, but is easy and convenient for tasks that don’t require the utmost security or uniqueness. During lightweight testing, between 1 and 10 million IDs can be generated without any collisions, and performance has been pretty good.

Implementations§

Source§

impl TinyId

Source

pub const LETTER_COUNT: usize = 64usize

The number of letters that make up the potential pool of characters for a TinyId.

Source

pub const LETTERS: [u8; 64]

The letter pool used during generation of a TinyId.

Source

pub const NULL_CHAR: u8 = 0u8

The byte used to represent null data / ids.

Source

pub const NULL_DATA: [u8; 8]

An instance of a fully null byte array, used as the basis for null ids.

Source

pub const fn is_valid_byte(byte: u8) -> bool

Test whether the given byte is valid for use as one of the 8 bytes in a TinyId.

This function exists because I’m tired of writing if LETTERS.contains(&byte) everywhere. Hopefully it is also more efficient to do it this way. Letters (as u8): [45, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122] aka [45, 48..=57, 65..=90, 95, 97..=122]

Source

pub fn null() -> Self

Create an instance of the null TinyId.

Examples found in repository?
examples/basic.rs (line 48)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn random() -> Self

Create a new random TinyId.

Examples found in repository?
examples/collision.rs (line 30)
27fn get_collision() -> usize {
28    let mut ids = std::collections::HashSet::new();
29    loop {
30        let id = TinyId::random();
31        if !ids.insert(id) {
32            break;
33        }
34    }
35    ids.len()
36}
More examples
Hide additional examples
examples/collision_average.rs (line 47)
42fn run_until_collision() -> usize {
43    let mut ids = std::collections::HashSet::new();
44    let mut iters = 0;
45    loop {
46        iters += 1;
47        let id = TinyId::random();
48        if !ids.insert(id) {
49            break;
50        }
51    }
52    iters
53}
examples/sample.rs (line 14)
11fn main() {
12    println!("Generating {ITERS} TinyIds...");
13    for x in (0..(ITERS)).step_by(2) {
14        let id = TinyId::random();
15        let mut n = x + 1;
16        print!("#{n:03}: {id}");
17        print!(" | ");
18        let id = TinyId::random();
19        n += 1;
20        println!("#{n:03}: {id}");
21    }
22}
examples/basic.rs (line 7)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn is_valid(self) -> bool

Checks whether this TinyId is null or has any invalid bytes.

Examples found in repository?
examples/basic.rs (line 46)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn is_null(self) -> bool

Checks whether this TinyId is null.

Examples found in repository?
examples/basic.rs (line 47)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn make_null(&mut self)

Makes this TinyId null.

Examples found in repository?
examples/basic.rs (line 50)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn from_str_unchecked(s: &str) -> Self

Convert from &str to TinyId, without checking the length or individual characters of the input.

Examples found in repository?
examples/basic.rs (line 16)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn to_bytes(self) -> [u8; 8]

Convert this TinyId to an array of 8 bytes.

Source

pub fn from_u64(n: u64) -> Result<Self, TinyIdError>

Attempt to create a new TinyId from a u64.

§Errors
Source

pub fn from_u64_unchecked(n: u64) -> Self

Creates a new TinyId from the given u64, without validating that the bytes are valid.

Source

pub fn to_u64(self) -> u64

Convert this TinyId to a u64 representation.

Source

pub fn from_bytes(bytes: [u8; 8]) -> Result<Self, TinyIdError>

Attempt to create a new TinyId from the given byte array.

§Errors
Source

pub fn from_bytes_unchecked(bytes: [u8; 8]) -> Self

Creates a new TinyId from the given [u8; 8], without validating that the bytes are valid.

Source

pub fn starts_with(&self, input: &str) -> bool

Checks whether this TinyId starts with the given string. This converts self to string so any associated overhead is incurred.

Examples found in repository?
examples/basic.rs (line 37)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}
Source

pub fn ends_with(&self, input: &str) -> bool

Checks whether this TinyId ends with the given string. This converts self to string so any associated overhead is incurred.

Examples found in repository?
examples/basic.rs (line 38)
5fn main() {
6    // Create a random ID
7    let rand_id = TinyId::random();
8
9    // Parse a string into a Result<TinyId, TinyIdError> for possibly unsafe / invalid ID strings
10    let maybe = TinyId::from_str("AAAABBBB");
11    assert!(maybe.is_ok());
12    let bad = TinyId::from_str("AAAABBB");
13    assert!(bad.is_err());
14
15    // Parse a string you **KNOW** is safe into a TinyId
16    let parsed = TinyId::from_str_unchecked("AAAABBBB");
17
18    // All expected operations are available on TinyIds
19    // Equality is a simple byte comparison so it should be fast and cheap!
20    assert_eq!(maybe.unwrap(), parsed);
21
22    // IDs may be printed using Display or Debug
23    println!("Random ID: {rand_id}");
24    println!("Parsed ID: {parsed}");
25    println!(" Debug ID: {parsed:?}");
26
27    // IDs are small!
28    println!("TinyID Size: {}", std::mem::size_of::<TinyId>());
29
30    // IDs are case-sensitive
31    let parsed2 = TinyId::from_str_unchecked("aaaaBBBB");
32    assert_ne!(parsed, parsed2);
33
34    // Check whether an ID starts with a given string. Example use case would be providing a
35    // list of IDs to a user, and asking for a partial string to match against so the user
36    // doesn't have to type the entire thing.
37    assert!(parsed.starts_with("AAAA"));
38    assert!(parsed.ends_with("BBBB"));
39    assert!(!parsed.starts_with("BBBB"));
40
41    // IDs are copied when assigned.
42    let mut switched = parsed;
43    assert_eq!(switched, parsed);
44
45    // Validity can be checked, and a "marker" exists for null / invalid IDs.
46    assert!(switched.is_valid());
47    assert!(!switched.is_null());
48    assert_ne!(switched, TinyId::null());
49    // Mutable IDs can be made null. This change has no effect on the `parsed` variable.
50    switched.make_null();
51    assert!(!switched.is_valid());
52    assert!(switched.is_null());
53    assert_eq!(switched, TinyId::null());
54}

Trait Implementations§

Source§

impl Clone for TinyId

Source§

fn clone(&self) -> TinyId

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TinyId

Source§

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

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

impl Default for TinyId

Source§

fn default() -> Self

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

impl Display for TinyId

Source§

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

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

impl FromStr for TinyId

Source§

type Err = TinyIdError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for TinyId

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 Ord for TinyId

Source§

fn cmp(&self, other: &TinyId) -> 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<&[u8]> for TinyId

Source§

fn eq(&self, other: &&[u8]) -> bool

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

const 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<&[u8; 8]> for TinyId

Source§

fn eq(&self, other: &&[u8; 8]) -> bool

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

const 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<&TinyId> for TinyId

Source§

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

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

const 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<&Vec<u8>> for TinyId

Source§

fn eq(&self, other: &&Vec<u8>) -> bool

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

const 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<[u8; 8]> for &TinyId

Source§

fn eq(&self, other: &[u8; 8]) -> bool

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

const 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<[u8; 8]> for TinyId

Source§

fn eq(&self, other: &[u8; 8]) -> bool

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

const 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<TinyId> for &[u8]

Source§

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

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

const 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<TinyId> for &[u8; 8]

Source§

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

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

const 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<TinyId> for &TinyId

Source§

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

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

const 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<TinyId> for &Vec<u8>

Source§

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

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

const 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<TinyId> for [u8; 8]

Source§

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

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

const 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<TinyId> for Vec<u8>

Source§

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

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

const 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<Vec<u8>> for TinyId

Source§

fn eq(&self, other: &Vec<u8>) -> bool

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

const 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 TinyId

Source§

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

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

const 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 TinyId

Source§

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

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

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

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

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

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

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

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

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

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

impl<'a> TryFrom<&'a [u8]> for TinyId

Source§

type Error = TinyIdError

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

fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&[u8; 8]> for TinyId

Source§

type Error = TinyIdError

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

fn try_from(value: &[u8; 8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<[u8; 8]> for TinyId

Source§

type Error = TinyIdError

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

fn try_from(value: [u8; 8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for TinyId

Source§

type Error = TinyIdError

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

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for TinyId

Source§

impl Eq for TinyId

Source§

impl StructuralPartialEq for TinyId

Auto Trait Implementations§

§

impl Freeze for TinyId

§

impl RefUnwindSafe for TinyId

§

impl Send for TinyId

§

impl Sync for TinyId

§

impl Unpin for TinyId

§

impl UnwindSafe for TinyId

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.