mod private
{
#[ cfg( feature = "no_std" ) ]
extern crate alloc;
#[ cfg( feature = "no_std" ) ]
use alloc ::string;
#[ derive( Clone, Debug, PartialEq, Eq ) ]
pub struct Seed( String );
impl Seed
{
pub fn new< IntoString >( value: IntoString ) -> Self
where
IntoString: Into< String >,
{
Self( value.into() )
}
#[ must_use ] pub fn from_integer( src: u64 ) -> Self
{
Self( format!( "master_seed_{src}" ) )
}
pub fn random() -> Self
{
use rand :: { distributions ::Alphanumeric, Rng };
let str: String = rand ::thread_rng()
.sample_iter( &Alphanumeric )
.take( 16 )
.map(char ::from)
.collect();
debug_assert!( !str.is_empty() );
Self( str )
}
#[ must_use ] pub fn into_inner( self ) -> String
{
self.0
}
}
impl Default for Seed
{
fn default() -> Self
{
Self( "master_seed".to_owned() )
}
}
impl< IntoString > From< IntoString > for Seed
where
IntoString: Into< String >,
{
#[ inline( always ) ]
fn from( src: IntoString ) -> Self
{
Self ::new( src )
}
}
}
crate ::mod_interface!
{
orphan use Seed;
}