Lines Matching full:uuid

2 // Copyright 2018 The Uuid Project Developers.
12 //! A Builder type for [`Uuid`]s.
14 //! [`Uuid`]: ../struct.Uuid.html
21 impl Uuid { impl
22 /// The 'nil UUID'.
24 /// The nil UUID is special form of UUID that is specified to have all
34 /// use uuid::Uuid;
36 /// let uuid = Uuid::nil();
39 /// uuid.to_hyphenated().to_string(),
44 Uuid::from_bytes([0; 16]) in nil()
47 /// Creates a UUID from four field values in big-endian order.
58 /// use uuid::Uuid;
62 /// let uuid = Uuid::from_fields(42, 12, 5, &d4);
63 /// let uuid = uuid.map(|uuid| uuid.to_hyphenated().to_string());
68 /// assert_eq!(expected_uuid, uuid);
75 ) -> Result<Uuid, crate::Error> { in from_fields() argument
84 Ok(Uuid::from_bytes([ in from_fields()
104 /// Creates a UUID from four field values in little-endian order.
112 /// use uuid::Uuid;
119 /// let uuid = Uuid::from_fields_le(d1, d2, d3, &d4);
120 /// let uuid = uuid.map(|uuid| uuid.to_hyphenated().to_string());
125 /// assert_eq!(expected_uuid, uuid);
132 ) -> Result<Uuid, crate::Error> { in from_fields_le() argument
141 Ok(Uuid::from_bytes([ in from_fields_le()
161 /// Creates a UUID from a 128bit value in big-endian order.
163 Uuid::from_bytes([ in from_u128()
183 /// Creates a UUID from a 128bit value in little-endian order.
185 Uuid::from_bytes([ in from_u128_le()
205 /// Creates a UUID using the supplied big-endian bytes.
216 /// use uuid::Uuid;
220 /// let uuid = Uuid::from_slice(&bytes);
221 /// let uuid = uuid.map(|uuid| uuid.to_hyphenated().to_string());
226 /// assert_eq!(expected_uuid, uuid);
232 /// use uuid::Uuid;
236 /// let uuid = Uuid::from_slice(&bytes);
238 /// assert!(uuid.is_err());
240 pub fn from_slice(b: &[u8]) -> Result<Uuid, crate::Error> { in from_slice() argument
251 Ok(Uuid::from_bytes(bytes)) in from_slice()
254 /// Creates a UUID using the supplied big-endian bytes.
255 pub const fn from_bytes(bytes: Bytes) -> Uuid { in from_bytes() argument
256 Uuid(bytes) in from_bytes()
260 /// A builder struct for creating a UUID.
264 /// Creating a v4 UUID from externally generated bytes:
267 /// use uuid::{Builder, Variant, Version};
274 /// let uuid = Builder::from_bytes(random_bytes)
292 /// let bytes: uuid::Bytes = [
296 /// let mut builder = uuid::Builder::from_bytes(bytes);
297 /// let uuid = builder.build().to_hyphenated().to_string();
301 /// assert_eq!(expected_uuid, uuid);
307 /// let bytes: uuid::Bytes = [4, 54, 67, 12, 43, 2, 98, 76]; // doesn't compile
309 /// let uuid = uuid::Builder::from_bytes(bytes);
328 /// let builder = uuid::Builder::from_slice(&bytes);
329 /// let uuid =
335 /// assert_eq!(expected_uuid, uuid);
343 /// let builder = uuid::Builder::from_slice(&bytes);
374 /// let builder = uuid::Builder::from_fields(42, 12, 5, &d4);
375 /// let uuid =
381 /// assert_eq!(expected_uuid, uuid);
389 /// let builder = uuid::Builder::from_fields(42, 12, 5, &d4);
399 Uuid::from_fields(d1, d2, d3, d4).map(|uuid| { in from_fields()
400 let bytes = *uuid.as_bytes(); in from_fields()
408 crate::Builder::from_bytes(*Uuid::from_u128(v).as_bytes()) in from_u128()
411 /// Creates a `Builder` with an initial [`Uuid::nil`].
418 /// use uuid::Builder;
431 /// Specifies the variant of the UUID.
445 /// Specifies the version number of the UUID.
452 /// Hands over the internal constructed [`Uuid`].
459 /// use uuid::Builder;
461 /// let uuid = Builder::nil().build();
464 /// uuid.to_hyphenated().to_string(),
469 /// [`Uuid`]: struct.Uuid.html
470 pub fn build(&mut self) -> Uuid { in build() argument
471 Uuid::from_bytes(self.0) in build()