Module rand.sys stdlib

rand.sys
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
3
Imported by:
0
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

This section is empty.

Aliases

This section is empty.

Constants

#constant seed_len

pub const seed_len = 1

Sum types

This section is empty.

Functions

This section is empty.

Structs

#struct SysRNG

pub struct SysRNG {
	buffer.PRNGBuffer
mut:
	seed u32 = seed.time_seed_32()
}

SysRNG is the PRNG provided by default in the libc implementiation that V uses.

#fn (&SysRNG) seed

fn (mut r &SysRNG) seed(seed_data []u32)

r.seed() sets the seed of the accepting SysRNG to the given data.

#fn (SysRNG) default_rand

inline
fn (r SysRNG) default_rand() int

r.default_rand() exposes the default behavior of the system's RNG (equivalent to calling C.rand()). Recommended for testing/comparison b/w V and other languages using libc and not for regular use.

This is also a one-off feature of SysRNG, similar to the global seed situation. Other generators will not have this.

#fn (&SysRNG) u8

inline
fn (mut r &SysRNG) u8() u8

byte returns a uniformly distributed pseudorandom 8-bit unsigned positive byte.

#fn (&SysRNG) u16

inline
fn (mut r &SysRNG) u16() u16

u16 returns a uniformly distributed pseudorandom 16-bit unsigned positive u16.

#fn (SysRNG) u32

inline
fn (r SysRNG) u32() u32

u32 returns a uniformly distributed pseudorandom 32-bit unsigned positive u32.

#fn (SysRNG) u64

inline
fn (r SysRNG) u64() u64

u64 returns a uniformly distributed pseudorandom 64-bit unsigned positive u64.

#fn (SysRNG) block_size

inline
fn (r SysRNG) block_size() int

block_size returns the number of bits that the RNG can produce in a single iteration.

#fn (&SysRNG) free

unsafe
fn (mut rng &SysRNG) free()

free should be called when the generator is no longer needed

Interfaces

This section is empty.

Enums

This section is empty.