gxid

Types

A library implementing XID generation Message handled by the actor

pub opaque type Message

Actor’s State internal representation

pub opaque type State

XID representation

This is an opaque type to ensure its RO nature

pub opaque type XID

Functions

pub fn generate(channel: Subject(Message)) -> XID

Generates a XID

Usage

import gxid.{XID}

let assert Ok(channel) = gxid.start()

let xid: XID = gxid.generate(channel)

See: https:///hexdocs.pm/gleam_otp/0.1.1/gleam/otp/actor/#call

pub fn machine_id(xid: XID) -> Int

Returns machine id from XID type

pub fn parse(str_xid: String) -> XID

Parse a XID string to have its composition

Usage

import gxid.{XID}

let xid: XID = gxid.parse("h8a8u4o00de6hq6tsc00")
pub fn pid(xid: XID) -> Int

Returns PID from XID type

pub fn random_number(xid: XID) -> Int

Returns random number from XID type

pub fn start() -> Result(Subject(Message), StartError)

Starts State generator

pub fn string(xid: XID) -> String

Returns xid string representation from XID type

pub fn time(xid: XID) -> Int

Returns time from XID type

pub fn to_xid(bit_xid: BitArray) -> XID

Copy a BitArray to a new XID and encode

Search Document