Struct cuid2::CuidConstructor
source · pub struct CuidConstructor { /* 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 with_length(self, length: u16) -> Self
pub const fn with_length(self, length: u16) -> Self
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) -> Self
pub const fn with_counter(self, counter: fn() -> u64) -> Self
Returns a new constructor with the specified counter function.
sourcepub const fn with_fingerprinter(self, fingerprinter: fn() -> String) -> Self
pub const fn with_fingerprinter(self, fingerprinter: fn() -> String) -> Self
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§
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