Lines Matching +full:d3 +full:- +full:dispatch
1 // Copyright 2013-2014 The Rust Project Developers.
4 // See the COPYRIGHT file at the top-level directory of this distribution.
6 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
17 //! 67e55044-10b1-426f-9247-bb680e5fe0c8
20 //! A UUID is a unique 128-bit value, stored as 16 octets, and regularly
34 …itions [in draft](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04).
45 //! "fast-rng", # Use a faster (but still sufficiently random) RNG
46 //! "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
68 //! const ID: Uuid = uuid!("67e55044-10b1-426f-9247-bb680e5fe0c8");
79 //! * `v1` - Version 1 UUIDs using a timestamp and monotonic counter.
80 //! * `v3` - Version 3 UUIDs based on the MD5 hash of some data.
81 //! * `v4` - Version 4 UUIDs with random data.
82 //! * `v5` - Version 5 UUIDs based on the SHA1 hash of some data.
83 //! * `v6` - Version 6 UUIDs using a timestamp and monotonic counter.
84 //! * `v7` - Version 7 UUIDs using a Unix timestamp.
85 //! * `v8` - Version 8 UUIDs using user-defined data.
90 //! version without any additional dependencies or features. It's a lower-level API than [`Uuid`]
106 //! * `macro-diagnostics` - enhances the diagnostics of `uuid!` macro.
107 //! * `serde` - adds the ability to serialize and deserialize a UUID using
109 //! * `borsh` - adds the ability to serialize and deserialize a UUID using
111 //! * `arbitrary` - adds an `Arbitrary` trait implementation to `Uuid` for
113 //! * `fast-rng` - uses a faster algorithm for generating random UUIDs.
116 //! * `bytemuck` - adds a `Pod` trait implementation to `Uuid` for byte manipulation
123 //! * `zerocopy` - adds support for zero-copy deserialization using the
129 //! normal, but also pass an additional flag through your environment to opt-in
133 //! RUSTFLAGS="--cfg uuid_unstable"
160 //! default-features = false
163 //! Some additional features are supported in no-std environments:
168 //! If you need to use `v4` or `v7` in a no-std environment, you'll need to
180 //! # fn main() -> Result<(), uuid::Error> {
206 …ormats, Version 4](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04)
208 //! [`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
209 //! [`cargo-web`]: https://crates.io/crates/cargo-web
215 html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
216 html_favicon_url = "https://www.rust-lang.org/favicon.ico",
245 // Soft-deprecated (Rust doesn't support deprecating re-exports)
274 #[cfg(feature = "macro-diagnostics")]
286 /// A 128-bit (16 byte) buffer containing the UUID.
297 /// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3)
312 /// Version 5: SHA-1 hash.
328 /// * [Variant in RFC4122](http://tools.ietf.org/html/rfc4122#section-4.1.1)
351 /// # fn main() -> Result<(), uuid::Error> {
379 /// `a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8`.
380 /// * [`urn`](#method.urn): `urn:uuid:A1A2A3A4-B1B2-C1C2-D1D2-D3D4D5D6D7D8`.
381 /// * [`braced`](#method.braced): `{a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8}`.
388 /// # fn main() -> Result<(), uuid::Error> {
392 /// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
403 /// # fn main() -> Result<(), uuid::Error> {
407 /// "urn:uuid:a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
417 /// value in big-endian order. This crate assumes integer inputs are already in
427 /// - The endianness is in terms of the fields of the UUID, not the environment.
428 /// - The endianness is assumed to be big-endian when there's no `_le` suffix
430 /// - Byte-flipping in `_le` methods applies to each integer.
431 /// - Endianness roundtrips, so if you create a UUID with `from_fields_le`
490 /// # fn main() -> Result<(), uuid::Error> {
491 /// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
500 /// * [Variant in RFC4122](http://tools.ietf.org/html/rfc4122#section-4.1.1)
501 pub const fn get_variant(&self) -> Variant { in get_variant()
517 /// This method is the future-proof alternative to [`Uuid::get_version`].
525 /// # fn main() -> Result<(), uuid::Error> {
526 /// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
535 /// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3)
536 pub const fn get_version_num(&self) -> usize { in get_version_num()
555 /// # fn main() -> Result<(), uuid::Error> {
556 /// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
565 /// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3)
566 pub const fn get_version(&self) -> Option<Version> { in get_version()
588 /// digits, taken as a big-endian `u32` value. For V1 UUIDs, this field
591 /// digits, taken as a big-endian `u16` value. For V1 UUIDs, this field
594 /// taken as a big-endian `u16` value. The 4 most significant bits give
598 /// hex digits, taken in order. The first 1-3 bits of this indicate the
599 /// UUID variant, and for V1 UUIDs, the next 13-15 bits indicate the clock
606 /// # fn main() -> Result<(), uuid::Error> {
611 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
625 pub fn as_fields(&self) -> (u32, u16, u16, &[u8; 8]) { in as_fields()
635 let d3 = (bytes[6] as u16) << 8 | (bytes[7] as u16); localVariable
638 (d1, d2, d3, d4)
641 /// Returns the four field values of the UUID in little-endian order.
644 /// big-endian order. This is based on the endianness of the UUID,
653 /// # fn main() -> Result<(), uuid::Error> {
654 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
668 pub fn to_fields_le(&self) -> (u32, u16, u16, &[u8; 8]) { in to_fields_le()
676 let d3 = (self.as_bytes()[6] as u16) | (self.as_bytes()[7] as u16) << 8; localVariable
679 (d1, d2, d3, d4)
690 /// # fn main() -> Result<(), uuid::Error> {
691 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
700 pub const fn as_u128(&self) -> u128 { in as_u128()
704 /// Returns a 128bit little-endian value containing the value.
706 /// The bytes in the `u128` will be flipped to convert into big-endian
713 /// than reversing the individual fields in-place.
719 /// # fn main() -> Result<(), uuid::Error> {
720 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
729 pub const fn to_u128_le(&self) -> u128 { in to_u128_le()
743 /// # fn main() -> Result<(), uuid::Error> {
744 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
752 pub const fn as_u64_pair(&self) -> (u64, u64) { in as_u64_pair()
784 pub const fn as_bytes(&self) -> &Bytes { in as_bytes()
804 pub const fn into_bytes(self) -> Bytes { in into_bytes()
808 /// Returns the bytes of the UUID in little-endian order.
810 /// The bytes will be flipped to convert into little-endian order. This is
819 /// # fn main() -> Result<(), uuid::Error> {
820 /// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
832 pub const fn to_bytes_le(&self) -> Bytes { in to_bytes_le()
841 pub const fn is_nil(&self) -> bool { in is_nil()
846 pub const fn is_max(&self) -> bool { in is_max()
867 /// "00000000-0000-0000-0000-000000000000"
872 /// "urn:uuid:00000000-0000-0000-0000-000000000000"
875 pub const fn encode_buffer() -> [u8; fmt::Urn::LENGTH] { in encode_buffer()
884 /// The V1 timestamp format defined in RFC4122 specifies a 60-bit
885 /// integer representing the number of 100-nanosecond intervals
889 /// value into more commonly-used formats, such as a unix timestamp.
898 pub const fn get_timestamp(&self) -> Option<Timestamp> { in get_timestamp()
930 fn default() -> Self { in default()
937 fn as_ref(&self) -> &[u8] { in as_ref()
944 fn from(value: Uuid) -> Self { in from()
953 fn try_from(value: std::vec::Vec<u8>) -> Result<Self, Self::Error> { in try_from()
962 …//! This module contains adapters you can use with [`#[serde(with)]`](https://serde.rs/field-attrs…
991 pub const fn new() -> Uuid { in new()
998 pub const fn new2() -> Uuid { in new2()
1061 || c == '-'); in test_uuid_display()
1081 || c == '-'); in test_uuid_lowerhex()
1129 || c == '-'); in test_uuid_to_string()
1214 "6ba7b810-9dad-11d1-80b4-00c04fd430c8" in test_predefined_namespaces()
1218 "6ba7b811-9dad-11d1-80b4-00c04fd430c8" in test_predefined_namespaces()
1222 "6ba7b812-9dad-11d1-80b4-00c04fd430c8" in test_predefined_namespaces()
1226 "6ba7b814-9dad-11d1-80b4-00c04fd430c8" in test_predefined_namespaces()
1241 let uuid = Uuid::new_v3(&Uuid::NAMESPACE_DNS, "rust-lang.org".as_bytes()); in test_get_version_v3()
1258 let uuid2 = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000").unwrap(); in test_get_variant()
1259 let uuid3 = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8").unwrap(); in test_get_variant()
1261 let uuid5 = Uuid::parse_str("F9168C5E-CEB2-4faa-D6BF-329BF39FA1E4").unwrap(); in test_get_variant()
1262 let uuid6 = Uuid::parse_str("f81d4fae-7dec-11d0-7765-00a0c91e6bf6").unwrap(); in test_get_variant()
1303 assert!(s.chars().all(|c| c.is_digit(16) || c == '-')); in test_hyphenated_string()
1332 || c == '-'); in test_upper_lower_hex()
1335 || c == '-'); in test_upper_lower_hex()
1338 || c == '-'); in test_upper_lower_hex()
1341 || c == '-'); in test_upper_lower_hex()
1345 || c == '-'); in test_upper_lower_hex()
1350 || c == '-'); in test_upper_lower_hex()
1356 || c == '-'); in test_upper_lower_hex()
1361 || c == '-'); in test_upper_lower_hex()
1382 assert!(s.chars().all(|c| c.is_digit(16) || c == '-')); in test_to_urn_string()
1400 let hsn = hs.chars().filter(|&c| c != '-').collect::<String>(); in test_to_simple_string_matching()
1438 let d3: u16 = 0xc1c2; in test_from_fields() localVariable
1441 let u = Uuid::from_fields(d1, d2, d3, &d4); in test_from_fields()
1460 let d3: u16 = 0xc2c1; in test_from_fields_le() localVariable
1463 let u = Uuid::from_fields_le(d1, d2, d3, &d4); in test_from_fields_le()
1481 let (d1, d2, d3, d4) = u.as_fields(); in test_as_fields()
1485 assert_ne!(d3, 0); in test_as_fields()