pub trait IdGenerator<T> {
type Error: Error;
// Required method
fn next_id(&self) -> Result<T, Self::Error>;
// Provided methods
fn format_id(&self, id: &T) -> String
where T: Display { ... }
fn next_string(&self) -> Result<String, Self::Error>
where T: Display { ... }
}Expand description
Generates IDs of type T.
The trait keeps the generated representation generic while still providing a
string-producing helper. Numeric generators normally use the default
Display based formatting. Generators with specialized textual forms can
override IdGenerator::format_id.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn next_string(&self) -> Result<String, Self::Error>where
T: Display,
fn next_string(&self) -> Result<String, Self::Error>where
T: Display,
Generates the next ID and formats it as a string.
§Returns
String representation of the next ID.
§Errors
Returns the same error as IdGenerator::next_id.