pub struct RandomIds { /* private fields */ }Expand description
Mints session identities from the operating system’s CSPRNG.
Cheap to construct, Sync, and safe to share: IdSource::next_session_id
takes &self, so one instance serves every session a server opens.
§Examples
use protocol_droid::adapters::secondary::id_source::RandomIds;
use protocol_droid::application::session::IdSource;
let ids = RandomIds::new()?;
let first = ids.next_session_id();
let second = ids.next_session_id();
assert_ne!(first, second);Implementations§
Source§impl RandomIds
impl RandomIds
Sourcepub fn new() -> Result<Self, EntropyError>
pub fn new() -> Result<Self, EntropyError>
Seed a source from the operating system.
§Errors
Returns EntropyError::Unavailable if the platform entropy source
cannot be read. Constructing from a hardcoded seed would make this type
a counter with extra steps, so the failure is reported rather than
papered over.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RandomIds
impl RefUnwindSafe for RandomIds
impl Send for RandomIds
impl Sync for RandomIds
impl Unpin for RandomIds
impl UnsafeUnpin for RandomIds
impl UnwindSafe for RandomIds
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