Skip to content

Latest commit

 

History

History
133 lines (88 loc) · 4.55 KB

docs.md

File metadata and controls

133 lines (88 loc) · 4.55 KB

sqlite-fastrand Documentation

A full reference to every function and module that sqlite-fastrand offers.

As a reminder, sqlite-fastrand follows semver and is pre v1, so breaking changes are to be expected.

API Reference

fastrand_version()

Returns the semver version string of the current version of sqlite-fastrand.

select fastrand_version(); -- "v0.1.0"

fastrand_debug()

Returns a debug string of various info about sqlite-fastrand, including the version string, build date, and commit hash.

select fastrand_debug();
'Version: v0.1.0
Source: 247dca8f4cea1abdc30ed3e852c3e5b71374c177'

fastrand_seed_get()

Gets the current seed value powering the underlying random number generator. Returns text, because the seed is an unsigned 64 bit integer, larger than SQLite's max integer size. Based on Rng.get_seed().

select fastrand_seed_get(); -- '3362862862133652073'

fastrand_seed_set()

Set the seed value of the underlying random number generator. Only i64 values allows. Returns 1 if succesful. Based on Rng.seed().

select fastrand_seed_set(); -- 1

fastrand_double()

Returns a random number between 0 and 1. Based on [Rng.f64()]https://docs.rs/fastrand/1.8.0/fastrand/struct.Rng.html#method.f64().

select fastrand_double(); -- 0.644268998061438
select fastrand_double(); -- 0.810443374870184

fastrand_int()

Returns a random 32 bit integer between -2_147_483_648 and 2_147_483_647. Based on Rng.i32().

select fastrand_int(); -- 1321083668
select fastrand_int(); -- 1579705906

fastrand_int64()

Returns a random 64 bit integer between -9_223_372_036_854_775_808 and 9_223_372_036_854_775_807. Based on Rng.i64().

select fastrand_int64(); -- -6587368321689545426
select fastrand_int64(); -- 7259195115703397710

fastrand_blob(N)

Returns a blob of length N with random bytes. Based on Rng.u8().

select fastrand_blob(4); -- X'bc71ef5b'
select fastrand_blob(12); -- X'22fce3c0c809c20b0c54251e'

fastrand_bool()

Returns a random boolean value, 0 or 1. Based on Rng.bool.

select fastrand_bool(); -- 1
select fastrand_bool(); -- 0

fastrand_alphabetic()

Returns a random alphabetic character, within a-z and A-Z. Based on Rng.alphabetic.

select fastrand_alphabetic(); -- 'Q'
select fastrand_alphabetic(); -- 'b'

fastrand_alphanumeric()

Returns a random alphanumeric character, within a-z, A-Z, or 0-9. Based on Rng.alphanumeric.

select fastrand_alphanumeric(); -- 'U'
select fastrand_alphanumeric(); -- '4'
select fastrand_alphanumeric(); -- 'i'

fastrand_digit(base)

Returns a random digit in the given base. The base must be greater than 0 and less than 36. Based on Rng.digit.

select fastrand_digit(4); -- '1'
select fastrand_digit(35); -- 'v'

fastrand_lowercase()

Returns a random character within a-z. Based on Rng.lowercase().

select fastrand_lowercase(); -- 's'
select fastrand_lowercase(); -- 'p'

fastrand_uppercase()

Returns a random character within A-Z. Based on Rng.uppercase().

select fastrand_uppercase(); -- 'E'
select fastrand_uppercase(); -- 'J'