Skip to main content

SourceKind

Enum SourceKind 

Source
#[non_exhaustive]
pub enum SourceKind {
Show 25 variants EnvOverride, FileOverride, Container, Lxc, MachineId, DbusMachineId, Dmi, LinuxHostId, IoPlatformUuid, WindowsMachineGuid, FreeBsdHostId, KenvSmbios, BsdKernHostId, IllumosHostId, AwsImds, GcpMetadata, AzureImds, DigitalOceanMetadata, HetznerMetadata, OciMetadata, OpenStackMetadata, KubernetesPodUid, KubernetesServiceAccount, KubernetesDownwardApi, Custom(&'static str),
}
Expand description

Short, stable label identifying a source.

Covers every built-in source plus a SourceKind::Custom variant for consumer-defined sources. Displayed in error messages, logs, and on the resolved crate::HostId.

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.
§

EnvOverride

Environment-variable override.

§

FileOverride

File-path override.

§

Container

Container runtime ID extracted from /proc/self/mountinfo (Linux).

§

Lxc

LXC/LXD container name from /proc/self/cgroup or /proc/self/mountinfo, salted with /etc/machine-id (Linux).

§

MachineId

/etc/machine-id (Linux).

§

DbusMachineId

/var/lib/dbus/machine-id (Linux).

§

Dmi

/sys/class/dmi/id/product_uuid — SMBIOS system UUID (Linux).

§

LinuxHostId

/etc/hostid — glibc 4-byte legacy host identifier (Linux).

§

IoPlatformUuid

IOPlatformUUID from IOPlatformExpertDevice (macOS).

§

WindowsMachineGuid

HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid (Windows).

§

FreeBsdHostId

/etc/hostid (FreeBSD).

§

KenvSmbios

kenv smbios.system.uuid (FreeBSD SMBIOS).

§

BsdKernHostId

sysctl kern.hostid (NetBSD, OpenBSD).

§

IllumosHostId

hostid(1) (illumos, Solaris).

§

AwsImds

AWS EC2 instance ID via IMDSv2.

§

GcpMetadata

GCP Compute Engine numeric instance ID via the metadata server.

§

AzureImds

Azure VM UUID via the Azure Instance Metadata Service.

§

DigitalOceanMetadata

DigitalOcean Droplet numeric ID.

§

HetznerMetadata

Hetzner Cloud numeric server ID.

§

OciMetadata

Oracle Cloud Infrastructure instance OCID.

§

OpenStackMetadata

OpenStack Nova instance UUID via the metadata service.

§

KubernetesPodUid

Kubernetes pod UID derived from /proc/self/mountinfo.

§

KubernetesServiceAccount

Kubernetes service-account namespace.

§

KubernetesDownwardApi

Kubernetes downward-API projected file.

§

Custom(&'static str)

Caller-supplied source; the payload is a short label for logs.

The label appears verbatim in Display and SourceKind::as_str output — a Custom("machine-id") renders identically to the built-in SourceKind::MachineId. Callers should pick labels that don’t collide with the built-in identifiers listed in crate::ids::source_ids so operators reading logs can tell which source a probe came from.

Implementations§

Source§

impl SourceKind

Source

pub const fn custom(label: &'static str) -> Self

Construct a SourceKind::Custom from a static string label.

Source

pub fn as_str(self) -> &'static str

Short, stable, lowercase name suitable for logs and telemetry.

Source

pub fn from_id(id: &str) -> Option<Self>

Inverse of SourceKind::as_str for the built-in identifiers.

Returns Some(kind) when id matches one of the stable strings returned by as_str for a non-Custom variant, None otherwise. SourceKind::Custom intentionally never round-trips through this — a runtime string cannot safely become a &'static str.

Source

pub fn describe(self) -> &'static str

One-line plain-text description of where this source reads its identifier from. Custom returns an empty string — callers supply their own labels.

Trait Implementations§

Source§

impl Clone for SourceKind

Source§

fn clone(&self) -> SourceKind

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 SourceKind

Source§

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

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

impl Display for SourceKind

Source§

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

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

impl Hash for SourceKind

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 PartialEq for SourceKind

Source§

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

Source§

impl Eq for SourceKind

Source§

impl StructuralPartialEq for SourceKind

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> 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> 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.