pub struct Identity { /* private fields */ }Expand description
An Identity for something interacting with the database.
An Identity is a 256-bit unsigned integer. These are encoded in various ways.
- In JSON, an
Identityis represented as a hexadecimal number wrapped in a string,"0x[64 hex characters]". - In BSATN, an
Identityis represented as a LITTLE-ENDIAN number 32 bytes long. - In memory, an
Identityis stored as a 256-bit number with the endianness of the host system.
If you are manually converting a hexadecimal string to a byte array like so:
"0xb0b1b2..."
->
[0xb0, 0xb1, 0xb2, ...]Make sure you call Identity::from_be_byte_array and NOT Identity::from_byte_array.
The standard way of writing hexadecimal numbers follows a big-endian convention, if you
index the characters in written text in increasing order from left to right.
Implementations§
Source§impl Identity
impl Identity
Sourcepub const fn from_byte_array(bytes: [u8; 32]) -> Self
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
Create an Identity from a LITTLE-ENDIAN byte array.
If you are parsing an Identity from a string, you probably want from_be_byte_array instead.
Sourcepub const fn from_be_byte_array(bytes: [u8; 32]) -> Self
pub const fn from_be_byte_array(bytes: [u8; 32]) -> Self
Create an Identity from a BIG-ENDIAN byte array.
This method is the correct choice if you have converted the bytes of a hexadecimal-formatted Identity
to a byte array in the following way:
"0xb0b1b2..."
->
[0xb0, 0xb1, 0xb2, ...]pub fn from_claims(issuer: &str, subject: &str) -> Self
Sourcepub fn to_byte_array(&self) -> [u8; 32]
pub fn to_byte_array(&self) -> [u8; 32]
Returns this Identity as a byte array.
Sourcepub fn to_be_byte_array(&self) -> [u8; 32]
pub fn to_be_byte_array(&self) -> [u8; 32]
Convert this Identity to a BIG-ENDIAN byte array.
Sourcepub fn abbreviate(&self) -> [u8; 8]
pub fn abbreviate(&self) -> [u8; 8]
Extract the first 8 bytes of this Identity as if it was stored in BIG-ENDIAN
format. (That is, the most significant bytes.)
Sourcepub fn to_abbreviated_hex(&self) -> HexString<8>
pub fn to_abbreviated_hex(&self) -> HexString<8>
Extract the first 16 characters of this Identity’s hexadecimal representation.
pub fn from_hex(hex: impl AsRef<[u8]>) -> Result<Self, FromHexError>
Trait Implementations§
Source§impl AsPrometheusLabel for Identity
Available on crate feature metrics_impls only.
impl AsPrometheusLabel for Identity
metrics_impls only.fn as_prometheus_str(&self) -> impl AsRef<str> + '_
Source§impl<'de> Deserialize<'de> for Identity
impl<'de> Deserialize<'de> for Identity
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
deserializer.Source§impl<'de> Deserialize<'de> for Identity
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Identity
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>
Source§impl From<Identity> for AlgebraicValue
impl From<Identity> for AlgebraicValue
Source§impl GroundSpacetimeType for Identity
impl GroundSpacetimeType for Identity
Source§fn get_type() -> AlgebraicType
fn get_type() -> AlgebraicType
AlgebraicType representation of Self.Source§impl Ord for Identity
impl Ord for Identity
Source§impl PartialOrd for Identity
impl PartialOrd for Identity
Source§impl SpacetimeType for Identity
impl SpacetimeType for Identity
Source§fn make_type<S: TypespaceBuilder>(_ts: &mut S) -> AlgebraicType
fn make_type<S: TypespaceBuilder>(_ts: &mut S) -> AlgebraicType
AlgebraicType representing the type for Self in SATS
and in the typing context in typespace. This is used by the
automatic type registration system in Rust modules. Read moreimpl Copy for Identity
impl Eq for Identity
impl StructuralPartialEq for Identity
Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnwindSafe for Identity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Col, Arg> IndexScanRangeBoundsTerminator for Argwhere
Arg: FilterableValue<Column = Col>,
impl<Col, Arg> IndexScanRangeBoundsTerminator for Argwhere
Arg: FilterableValue<Column = Col>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Satn for T
impl<T> Satn for T
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
f.Source§fn fmt_psql(
&self,
f: &mut Formatter<'_>,
ty: &PsqlType<'_>,
) -> Result<(), Error>
fn fmt_psql( &self, f: &mut Formatter<'_>, ty: &PsqlType<'_>, ) -> Result<(), Error>
f.Source§fn to_satn(&self) -> String
fn to_satn(&self) -> String
String.Source§fn to_satn_pretty(&self) -> String
fn to_satn_pretty(&self) -> String
String.