Stof Docs
Star on GitHubStof WebsiteDiscordContact Us
  • 🚀Welcome
  • â„šī¸Resources & Information
  • Book
    • Data Interface
    • Introduction & Design
    • Host Environments
      • Rust
      • TypeScript
        • Extend Stof
        • Import Statement
    • Data Interchange
      • JSON to Stof
      • Importing and Parsing Data
      • Exporting Data
      • REST and Restructure
    • Configuration Files
    • Schemas
      • Renaming Fields
      • Removing Fields
      • Validation & Transformation
        • Example Access
      • Nested Schemas
    • Orchestration
  • Common Concepts
    • Objects
    • Primitive Types
    • Functions
    • Fields
    • Object Types
    • Imports
    • Error Handling
    • Units
    • Casting/Conversions
  • Reference
    • CLI
      • 🏃Run
      • đŸ§ĒTest
      • 📚CLI Libraries
        • Filesystem Library
        • Time Library
        • HTTP Library
    • Stof Language
    • Libraries
      • Standard Library
      • Array/Vector Library
      • Number Library
      • String Library
      • Object Library
      • Function Library
      • Set Library
      • Map Library
      • Data Library
      • Tuple Library
      • Blob Library
      • Boolean Library
    • đŸĒ§Formats
Powered by GitBook
On this page
  • Common Value Functions
  • Blob.toString(blob: blob): str
  • Blob.or(blob: blob, ...): unknown
  • Blob Functions
  • Blob.len(blob: blob): int
  • Blob.at(blob: blob, index: int): int

Was this helpful?

  1. Reference
  2. Libraries

Blob Library

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

PreviousTuple LibraryNextBoolean Library

Last updated 4 months ago

Was this helpful?

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 "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");
}
Standard Library