Trait SnowflakeGeneratorAsyncExt

Source
pub trait SnowflakeGeneratorAsyncExt<ID, T>
where ID: Snowflake, T: TimeSource<ID::Ty>,
{ // Required method fn try_next_id_async<S>(&self) -> impl Future<Output = Result<ID>> where S: SleepProvider; }
Expand description

Extension trait for asynchronously generating Snowflake IDs.

This trait enables SnowflakeGenerator types to yield IDs in a Future-based context by awaiting until the generator is ready to produce a new ID.

The default implementation uses GeneratorFuture and a specified SleepProvider to yield when the generator is not yet ready.

Required Methods§

Source

fn try_next_id_async<S>(&self) -> impl Future<Output = Result<ID>>
where S: SleepProvider,

Returns a future that resolves to the next available Snowflake ID.

If the generator is not ready to issue a new ID immediately, the future will sleep for the amount of time indicated by the generator and retry.

§Errors

This future may return an error if the generator encounters one.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<G, ID, T> SnowflakeGeneratorAsyncExt<ID, T> for G
where G: SnowflakeGenerator<ID, T>, ID: Snowflake, T: TimeSource<ID::Ty>,