Skip to main content

Wrap

Enum Wrap 

Source
#[non_exhaustive]
pub enum Wrap { UuidV5Namespaced, UuidV5With(Uuid), UuidV3Nil, Passthrough, }
Expand description

How the raw identifier produced by a crate::Source is turned into a uuid::Uuid.

Pick one with crate::Resolver::with_wrap. The default (Wrap::UuidV5Namespaced) is the right choice for new code; the other variants exist for specific interop scenarios.

VariantWhen to use
UuidV5NamespacedDefault. Strongest collision resistance; rehashes under a private namespace so two tools sharing a raw source cannot collide.
UuidV5WithYou want v5 hashing but need the wrapped UUID to live in a namespace already used by another system.
UuidV3NilWire-compatible with the legacy Go derivation uuid.NewMD5(uuid.Nil, raw). Interop only; prefer v5 otherwise.
PassthroughThe source already yields a UUID and you want that exact UUID to survive unchanged (e.g. match another agent).

All deterministic: the same raw input always produces the same UUID.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UuidV5Namespaced

UUID v5 (SHA-1) under the crate’s DEFAULT_NAMESPACE. Default; strongest collision resistance of the deterministic options and the right choice unless you have a concrete interop requirement.

Rehashes the raw value even when the source already yields a UUID (DMI product_uuid, macOS IOPlatformUUID, Windows MachineGuid, SMBIOS). That is intentional: it prevents two tools that share a raw source (e.g. two agents both reading /etc/machine-id) from emitting colliding IDs. Use Wrap::Passthrough when you explicitly want the source’s own UUID to survive unchanged, or Wrap::UuidV5With when you need a different namespace.

§

UuidV5With(Uuid)

UUID v5 (SHA-1) under a caller-supplied namespace. Same algorithm as Wrap::UuidV5Namespaced with a different namespace constant.

Use when another system in your stack already hashes identifiers under a well-known namespace (e.g. a product-wide DNS namespace) and you want this crate’s output to sit in that same space so IDs cross-correlate. If you don’t have such a namespace, stick with the default.

§

UuidV3Nil

UUID v3 (MD5) under the nil namespace — wire-compatible with the legacy Go derivation uuid.NewMD5(uuid.Nil, raw).

Use only for interop with existing pipelines that already produced IDs this way; MD5 has no security relevance here, but RFC 9562 recommends v5 over v3 for new work and so does this crate.

§

Passthrough

Parse the raw value directly as a UUID, with no hashing.

Use when the source already yields a UUID string (DMI product_uuid, macOS IOPlatformUUID, Windows MachineGuid, kenv smbios.system.uuid, container IDs, Kubernetes pod UIDs) and you want that exact UUID to survive unchanged — for example, to match the ID another agent on the same host already reports.

Returns None (surfaced as crate::Error::Malformed from the resolver) when the raw value is not a parseable UUID, so this strategy is unsafe to pair with sources that emit arbitrary strings (e.g. HOST_IDENTITY=my-server).

Accepts every form uuid::Uuid::parse_str accepts — hyphenated (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), simple (no hyphens), braced ({…}), and the RFC-9562 urn:uuid:… form. The parsed UUID is returned in canonical form regardless of the input shape.

Implementations§

Source§

impl Wrap

Source

pub fn apply(self, raw: &str) -> Option<Uuid>

Apply this strategy to a raw identifier.

Returns None for Wrap::Passthrough when the raw value cannot be parsed as a UUID. All other strategies always succeed.

Trait Implementations§

Source§

impl Clone for Wrap

Source§

fn clone(&self) -> Wrap

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 Wrap

Source§

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

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

impl Default for Wrap

Source§

fn default() -> Wrap

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

impl PartialEq for Wrap

Source§

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

Source§

impl Eq for Wrap

Source§

impl StructuralPartialEq for Wrap

Auto Trait Implementations§

§

impl Freeze for Wrap

§

impl RefUnwindSafe for Wrap

§

impl Send for Wrap

§

impl Sync for Wrap

§

impl Unpin for Wrap

§

impl UnsafeUnpin for Wrap

§

impl UnwindSafe for Wrap

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

Source§

type Output = T

Should always be Self
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.