Skip to content

MemoryError ​

Signatureinterface MemoryError { readonly code: string; readonly message: string; }

zeroize returns MemoryError in the Err variant of Result<void, MemoryError>. Inspect it with match or propagate it with ?.

MemoryError has stable code and readable message fields. zeroize can return ERR_MEMORY_NOT_OWNED, ERR_MEMORY_SHARED_VALUE, or ERR_MEMORY_INVALID_VALUE.

tyrus
import { MemoryError, zeroize } from "tyrus:memory";

function main(): void {
    const literal = "api-key";
    match (zeroize(literal)) {
        Ok(_) => { print("erased"); }
        Err(error) => { print(error.code); // ERR_MEMORY_NOT_OWNED
        }
    }
}