Struct fire_postgres::UniqueId
source · pub struct UniqueId(/* private fields */);
Expand description
A UniqueId that can be used within a database. Is not cryptographically secure and could be bruteforced.
Contains 10bytes
- 0..5 are seconds since the UNIX_EPOCH
- 5..10 are random
Implementations§
source§impl UniqueId
impl UniqueId
pub fn new() -> UniqueId
sourcepub const fn from_raw(inner: [u8; 10]) -> UniqueId
pub const fn from_raw(inner: [u8; 10]) -> UniqueId
This creates a unique id with it’s raw content making it able to be called in a const context.
pub fn from_slice_unchecked(slice: &[u8]) -> UniqueId
pub fn to_b64(&self) -> String
sourcepub fn parse_from_b64<T>(b64: T) -> Result<UniqueId, DecodeError>
pub fn parse_from_b64<T>(b64: T) -> Result<UniqueId, DecodeError>
If the string is not 14 bytes long returns InvalidLength
pub fn from_bytes(bytes: [u8; 10]) -> UniqueId
pub fn into_bytes(self) -> [u8; 10]
pub fn since_unix_secs(&self) -> u64
pub fn as_slice(&self) -> &[u8] ⓘ
Trait Implementations§
source§impl ColumnType for UniqueId
impl ColumnType for UniqueId
fn column_kind() -> ColumnKind
source§impl<'r> FromSql<'r> for UniqueId
impl<'r> FromSql<'r> for UniqueId
source§fn from_sql(
ty: &Type,
raw: &'r [u8]
) -> Result<UniqueId, Box<dyn Error + Sync + Send>>
fn from_sql( ty: &Type, raw: &'r [u8] ) -> Result<UniqueId, Box<dyn Error + Sync + Send>>
Creates a new value of this type from a buffer of data of the specified
Postgres
Type
in its binary format. Read moresource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be created from the specified
Postgres
Type
.source§impl PartialEq for UniqueId
impl PartialEq for UniqueId
source§impl ToSql for UniqueId
impl ToSql for UniqueId
source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Converts the value of
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moresource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be converted to the specified
Postgres
Type
.source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
An adaptor method used internally by Rust-Postgres. Read more
source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
Specify the encode format
impl Copy for UniqueId
impl Eq for UniqueId
impl StructuralPartialEq for UniqueId
Auto Trait Implementations§
impl Freeze for UniqueId
impl RefUnwindSafe for UniqueId
impl Send for UniqueId
impl Sync for UniqueId
impl Unpin for UniqueId
impl UnwindSafe for UniqueId
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> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
Returns a reference to
self
as a ToSql
trait object.