Skip to main content

derive_range

Function derive_range 

Source
pub fn derive_range<T, E, F>(start: u32, count: u32, f: F) -> Result<Vec<T>, E>
where F: FnMut(u32) -> Result<T, E>, E: From<DeriveError>,
Expand description

Derive a range of accounts by repeatedly invoking a derivation closure.

Generic building block for every chain’s batch-derivation entry point: validates start + count against u32 overflow and collects the results into a Vec<T>.

§Errors

Returns DeriveError::Input (wrapped via E: From<DeriveError>) if start + count overflows u32, or propagates any error produced by f.

§Example

use kobe_primitives::{DerivedAccount, DeriveError, derive_range};

fn batch(count: u32) -> Result<Vec<DerivedAccount>, DeriveError> {
    derive_range(0, count, |_i| todo!("derive one"))
}