pub struct OrgId(/* private fields */);Expand description
A UUID v4 tenant identifier, typically propagated via the X-Org-Id
HTTP header.
Use OrgId::generate to create a fresh identifier, or FromStr /
TryFrom to parse one from an incoming header.
The Display implementation produces the canonical hyphenated UUID string
(e.g. 550e8400-e29b-41d4-a716-446655440000).
Implementations§
Source§impl OrgId
impl OrgId
Sourcepub const fn new(id: Uuid) -> Self
pub const fn new(id: Uuid) -> Self
Wrap an existing uuid::Uuid as an OrgId.
use api_bones::org_id::OrgId;
let id = OrgId::new(uuid::Uuid::nil());
assert_eq!(id.to_string(), "00000000-0000-0000-0000-000000000000");Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generate a new random OrgId (UUID v4).
use api_bones::org_id::OrgId;
let id = OrgId::generate();
assert_eq!(id.inner().get_version_num(), 4);Sourcepub fn inner(&self) -> Uuid
pub fn inner(&self) -> Uuid
Return the inner uuid::Uuid.
use api_bones::org_id::OrgId;
let uuid = uuid::Uuid::nil();
let id = OrgId::new(uuid);
assert_eq!(id.inner(), uuid);Trait Implementations§
Source§impl<'de> Deserialize<'de> for OrgId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for OrgId
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Copy for OrgId
impl Eq for OrgId
impl StructuralPartialEq for OrgId
Auto Trait Implementations§
impl Freeze for OrgId
impl RefUnwindSafe for OrgId
impl Send for OrgId
impl Sync for OrgId
impl Unpin for OrgId
impl UnsafeUnpin for OrgId
impl UnwindSafe for OrgId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP