pub struct Cuid2Constructor { /* private fields */ }Expand description
Provides customization of CUID generation.
use cuid2::CuidConstructor;
let mut constructor = CuidConstructor::new();
assert_eq!(24, constructor.create_id().len());
constructor.set_length(16);
assert_eq!(16, constructor.create_id().len());
assert_eq!(32, CuidConstructor::new().with_length(32).create_id().len());Implementations§
Source§impl CuidConstructor
impl CuidConstructor
Sourcepub const fn new() -> CuidConstructor
pub const fn new() -> CuidConstructor
Creates a new constructor with default settings.
Sourcepub const fn with_length(self, length: u16) -> CuidConstructor
pub const fn with_length(self, length: u16) -> CuidConstructor
Returns a new constructor that will generate CUIDs with the specified length.
§Panics
Panics if length is less than 2.
Sourcepub const fn with_counter(self, counter: fn() -> u64) -> CuidConstructor
pub const fn with_counter(self, counter: fn() -> u64) -> CuidConstructor
Returns a new constructor with the specified counter function.
Sourcepub const fn with_fingerprinter(
self,
fingerprinter: fn() -> String,
) -> CuidConstructor
pub const fn with_fingerprinter( self, fingerprinter: fn() -> String, ) -> CuidConstructor
Returns a new constructor with the specified fingerprinter function.
Sourcepub fn set_length(&mut self, length: u16)
pub fn set_length(&mut self, length: u16)
Sourcepub fn set_counter(&mut self, counter: fn() -> u64)
pub fn set_counter(&mut self, counter: fn() -> u64)
Sets the counter function for this constructor.
Sourcepub fn set_fingerprinter(&mut self, fingerprinter: fn() -> String)
pub fn set_fingerprinter(&mut self, fingerprinter: fn() -> String)
Sets the fingerperinter function for this constructor.
Trait Implementations§
Source§impl Default for CuidConstructor
impl Default for CuidConstructor
Source§fn default() -> CuidConstructor
fn default() -> CuidConstructor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CuidConstructor
impl RefUnwindSafe for CuidConstructor
impl Send for CuidConstructor
impl Sync for CuidConstructor
impl Unpin for CuidConstructor
impl UnwindSafe for CuidConstructor
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