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: ConnectionId
pub const fn from_u128(__connection_id__: u128) -> ConnectionId
pub const fn to_u128(&self) -> u128
Sourcepub const fn from_le_byte_array(arr: [u8; 16]) -> ConnectionId
pub const fn from_le_byte_array(arr: [u8; 16]) -> ConnectionId
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]) -> ConnectionId
pub const fn from_be_byte_array(arr: [u8; 16]) -> ConnectionId
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<ConnectionId, Error>
pub fn from_hex(hex: &str) -> Result<ConnectionId, 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]>) -> ConnectionId
pub fn from_be_slice(slice: impl AsRef<[u8]>) -> ConnectionId
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<ConnectionId>
Trait Implementations§
Source§impl Clone for ConnectionId
impl Clone for ConnectionId
Source§fn clone(&self) -> ConnectionId
fn clone(&self) -> ConnectionId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ConnectionId
Source§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: D,
) -> Result<ConnectionId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ConnectionId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
deserializer.Source§impl Display for ConnectionId
impl Display for ConnectionId
impl Eq 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) -> AlgebraicValue
fn from(value: ConnectionId) -> AlgebraicValue
Source§impl From<ConnectionIdForUrl> for ConnectionId
impl From<ConnectionIdForUrl> for ConnectionId
Source§fn from(addr: ConnectionIdForUrl) -> ConnectionId
fn from(addr: ConnectionIdForUrl) -> ConnectionId
Source§impl From<u128> for ConnectionId
impl From<u128> for ConnectionId
Source§fn from(value: u128) -> ConnectionId
fn from(value: u128) -> 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 (const: unstable) · 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§fn eq(&self, other: &ConnectionId) -> bool
fn eq(&self, other: &ConnectionId) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ConnectionId
impl PartialOrd for ConnectionId
Source§impl<T> RHS<T, ConnectionId> for ConnectionId
impl<T> RHS<T, ConnectionId> for ConnectionId
Source§impl Serialize for ConnectionId
impl Serialize for ConnectionId
Source§fn serialize<S>(
&self,
__serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
__serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
self in the data format of S using the provided serializer.Source§impl SpacetimeType for ConnectionId
impl SpacetimeType for ConnectionId
Source§fn make_type<S>(_ts: &mut S) -> AlgebraicTypewhere
S: TypespaceBuilder,
fn make_type<S>(_ts: &mut S) -> AlgebraicTypewhere
S: TypespaceBuilder,
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 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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§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.Source§impl<T> ToLeanString for Twhere
T: Display,
impl<T> ToLeanString for Twhere
T: Display,
Source§fn try_to_lean_string(&self) -> Result<LeanString, ToLeanStringError>
fn try_to_lean_string(&self) -> Result<LeanString, ToLeanStringError>
LeanString. Read moreSource§fn to_lean_string(&self) -> LeanString
fn to_lean_string(&self) -> LeanString
LeanString. Read more