Blob Library

Stof's standard blob library ("Blob").

Common Value Functions

Blob.toString(blob: blob): str

Returns this blob converted to a string.

Blob.or(blob: blob, ...): unknown

Returns the first non-empty (null or void) argument, just like the Standard Library "or" function.

#[test]
fn test() {
    let blb = self.dne.or("hello" as blob);
    assertEq(blb.len(), 5);
}

Blob Functions

Blob.len(blob: blob): int

Get the length of this blob (number of bytes (u8 values)).

#[test]
fn test() {
    let blb = "dude" as blob;
    assertEq(blb.len(), 4);
    assertEq(blb.size(), 4); // "size" is an alias in the Blob lib for "len"
}

Blob.at(blob: blob, index: int): int

Get the byte in this blob at a specific index.

#[test]
fn at() {
    let blb = "hello" as blob;
    let e = blb[1];
    let o = blb.at(4);
    assertEq(([e, o] as blob) as str, "eo");
}

Last updated