pub struct ConnectionId { /* private fields */ }Expand description
A unique identifier for a client connection to a SpacetimeDB database.
This is a special type.
A ConnectionId is a 128-bit unsigned integer. This can be serialized in various ways.
- In JSON, an
ConnectionIdis represented as a BARE DECIMAL number. This requires some care when deserializing; see https://stackoverflow.com/questions/69644298/how-to-make-json-parse-to-treat-all-the-numbers-as-bigint - In BSATN, a
ConnectionIdis represented as a LITTLE-ENDIAN number 16 bytes long. - In memory, a
ConnectionIdis stored as a 128-bit number with the endianness of the host system.
Implementations§
Source§impl ConnectionId
impl ConnectionId
pub const ZERO: Self
pub const fn from_u128(__connection_id__: u128) -> Self
pub const fn to_u128(&self) -> u128
Sourcepub const fn from_le_byte_array(arr: [u8; 16]) -> Self
pub const fn from_le_byte_array(arr: [u8; 16]) -> Self
Create an ConnectionId from a little-endian byte array.
If you are parsing an ConnectionId from a string,
you probably want Self::from_be_byte_array instead.
But if you need to convert a hexadecimal string to a ConnectionId,
just use Self::from_hex.
Sourcepub const fn from_be_byte_array(arr: [u8; 16]) -> Self
pub const fn from_be_byte_array(arr: [u8; 16]) -> Self
Create an ConnectionId from a big-endian byte array.
This method is the correct choice
if you have converted the bytes of a hexadecimal-formatted ConnectionId
to a byte array in the following way:
"0xb0b1b2..."
->
[0xb0, 0xb1, 0xb2, ...]But if you need to convert a hexadecimal string to a ConnectionId,
just use Self::from_hex.
Sourcepub const fn as_le_byte_array(&self) -> [u8; 16]
pub const fn as_le_byte_array(&self) -> [u8; 16]
Convert a ConnectionId to a little-endian byte array.
Sourcepub const fn as_be_byte_array(&self) -> [u8; 16]
pub const fn as_be_byte_array(&self) -> [u8; 16]
Convert a ConnectionId to a big-endian byte array.
This is a format suitable for printing as a hexadecimal string.
But if you need to convert a ConnectionId to a hexadecimal string,
just use Self::to_hex.
Sourcepub fn from_hex(hex: &str) -> Result<Self, Error>
pub fn from_hex(hex: &str) -> Result<Self, Error>
Parse a hexadecimal string into a ConnectionId.
Sourcepub fn abbreviate(&self) -> [u8; 8]
pub fn abbreviate(&self) -> [u8; 8]
Extract the first 8 bytes of this ConnectionId 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 ConnectionId’s hexadecimal representation.
Sourcepub fn from_be_slice(slice: impl AsRef<[u8]>) -> Self
pub fn from_be_slice(slice: impl AsRef<[u8]>) -> Self
Create an ConnectionId from a slice, assumed to be in big-endian format.
pub fn to_ipv6(self) -> Ipv6Addr
pub fn to_ipv6_string(self) -> String
pub fn none_if_zero(self) -> Option<Self>
Trait Implementations§
Source§impl AsPrometheusLabel for ConnectionId
Available on crate feature metrics_impls only.
impl AsPrometheusLabel for ConnectionId
metrics_impls only.fn as_prometheus_str(&self) -> impl AsRef<str> + '_
Source§impl Clone for ConnectionId
impl Clone for ConnectionId
Source§fn clone(&self) -> ConnectionId
fn clone(&self) -> ConnectionId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectionId
impl Debug for ConnectionId
Source§impl<'de> Deserialize<'de> for ConnectionId
impl<'de> Deserialize<'de> for ConnectionId
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 ConnectionId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ConnectionId
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for ConnectionId
impl Display for ConnectionId
Source§impl FilterableValue for &ConnectionId
impl FilterableValue for &ConnectionId
type Column = ConnectionId
Source§impl FilterableValue for ConnectionId
impl FilterableValue for ConnectionId
type Column = ConnectionId
Source§impl From<ConnectionId> for AlgebraicValue
impl From<ConnectionId> for AlgebraicValue
Source§fn from(value: ConnectionId) -> Self
fn from(value: ConnectionId) -> Self
Source§impl From<ConnectionId> for ConnectionIdForUrl
impl From<ConnectionId> for ConnectionIdForUrl
Source§fn from(addr: ConnectionId) -> Self
fn from(addr: ConnectionId) -> Self
Source§impl From<ConnectionIdForUrl> for ConnectionId
impl From<ConnectionIdForUrl> for ConnectionId
Source§fn from(addr: ConnectionIdForUrl) -> Self
fn from(addr: ConnectionIdForUrl) -> Self
Source§impl From<u128> for ConnectionId
impl From<u128> for ConnectionId
Source§impl GroundSpacetimeType for ConnectionId
impl GroundSpacetimeType for ConnectionId
Source§fn get_type() -> AlgebraicType
fn get_type() -> AlgebraicType
AlgebraicType representation of Self.Source§impl Hash for ConnectionId
impl Hash for ConnectionId
Source§impl Ord for ConnectionId
impl Ord for ConnectionId
Source§fn cmp(&self, other: &ConnectionId) -> Ordering
fn cmp(&self, other: &ConnectionId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ConnectionId
impl PartialEq for ConnectionId
Source§impl PartialOrd for ConnectionId
impl PartialOrd for ConnectionId
Source§impl Serialize for ConnectionId
impl Serialize for ConnectionId
Source§impl Serialize for ConnectionId
Available on crate feature serde only.
impl Serialize for ConnectionId
serde only.Source§impl SpacetimeType for ConnectionId
impl SpacetimeType for ConnectionId
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 ConnectionId
impl Eq for ConnectionId
impl StructuralPartialEq for ConnectionId
Auto Trait Implementations§
impl Freeze for ConnectionId
impl RefUnwindSafe for ConnectionId
impl Send for ConnectionId
impl Sync for ConnectionId
impl Unpin for ConnectionId
impl UnwindSafe for ConnectionId
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.