3.4 KiB
3.4 KiB
Suzu Runtime and Notation
Documentation
Conventions
Namespacing
Examples in this documentation will assume inclusion of the szun namespace. In practice, this is not recommended outside of limited scopes.
fn procedure()
{
use szun::*;
/* ... */
}
Type Building
Type building functions allow for the construction of identifiers representing complex data types. These identifiers are used to allocate typed
varying()
boolean()
natural()
integer()
block(size)
sequence()
array(size, type)
list(type)
schema()
record(schema)
Example
This example produces an identifier representing a list of blocks of 4 bytes each.
let type_id = list(block(4));
Global Functions
allocate(type)
let ref = allocate(list(integer()));
encode(ref:Reference) -> vec
decode(data:Vec) -> Reference
Language Compiler
Common Methods
new() -> Self
let value = Integer::new();
from(ref:Reference) -> Result<Self,()>
match Integer::from(list.at(0)) {
Ok(data) => { println!("Integer: {}", data); }
Err(_) => { println!("Not Integer"); }
}
with(value) -> Self
let b = Boolean::with(true);
Dereference
let ref = *Integer::new();
Varying
set(ref:Reference)
let var = Varying::new();
var.set(*Sequence::with("Hello!"))
get() -> Reference
let var = Varying::with(*Boolean::with(true));
let ref = var.get();
Boolean
Stores the value true or false.
get() -> bool
let value = Boolean::with(true);
if value.get() {
println!("True");
}
set(value:bool)
let mut value = Boolean::new();
value.set(true);
Natural
Stores a non-negative integer value.
get() -> u64
let value = Integer::with(-1);
println!("{}", value.get());
set(value:u64)
let mut value = Integer::new();
value.set(-273);
Integer
Stores a signed integer value.
get() -> i64
let value = Integer::with(-1);
println!("{}", value.get());
set(value:i64)
let mut value = Integer::new();
value.set(-273);
Block
Constant-sized series of bytes.
Sequence
Variable-sized series of bytes.
get() -> String
get_raw() -> Vec
set(data:&str)
set_raw(data:Vec)
Array
Constant-sized, ordered collection of items.
new(size:usize, type_id:usize)
length() -> usize
at(index:usize) -> Reference
set(index:usize, ref:Reference)
List
Variable-sized, ordered collection of items.
new(type_id:usize)
length() -> usize
capacity() -> usize
at(index:usize) -> Reference
set(index:usize, ref:Reference)
insert(index:usize, ref:Reference)
remove(index:usize)
reserve(capacity:usize)
clear()
Schema
Definition of an abstract structure composed of named items.
get(index:usize) -> usize
add(type_id:usize) -> usize
remove(index:usize)
assign(key:&str, type_id:usize) -> usize
map(key:&str, index:usize)
unmap(key:&str)
clear()
bind(id:usize)
Record
Instance of a schema.