Skip to main content

Crate packr_abi

Crate packr_abi 

Source
Expand description

Graph-encoded ABI for Pack runtime

This crate provides encoding and decoding for recursive data types using a graph-based binary format. It’s no_std compatible for use in WASM packages.

§Derive Macros

Enable the derive feature to use #[derive(GraphValue)]:

use packr_abi::{GraphValue, Value};

#[derive(GraphValue)]
struct Point {
    x: i64,
    y: i64,
}

let point = Point { x: 10, y: 20 };
let value: Value = point.into();
let back: Point = value.try_into().unwrap();

Structs§

Binding
An interface binding: name -> hash.
Decoder
Encoder
GraphBuffer
Limits
Node
ParseError
Parse error with position information.
TypeHash
A 256-bit type hash.
TypeHasher
Builder for computing type hashes.

Enums§

AbiError
ConversionError
Error type for Value conversions
NodeKind
Value
A runtime value that can be passed across package boundaries
ValueType
Runtime type representation for CGRF v2

Constants§

HASH_BOOL
Hash for the bool type.
HASH_CHAR
Hash for the char type.
HASH_F32
Hash for the f32 type.
HASH_F64
Hash for the f64 type.
HASH_FLAGS
Hash for the flags type.
HASH_S8
Hash for the s8 type.
HASH_S16
Hash for the s16 type.
HASH_S32
Hash for the s32 type.
HASH_S64
Hash for the s64 type.
HASH_SELF_REF
Placeholder for self-references in recursive types.
HASH_STRING
Hash for the string type.
HASH_U8
Hash for the u8 type.
HASH_U16
Hash for the u16 type.
HASH_U32
Hash for the u32 type.
HASH_U64
Hash for the u64 type.

Traits§

FromValue
Trait for converting from a Value.
GraphCodec
KnownValueType
Compile-time ValueType for a Rust type. Used by From<Vec<T>> and From<Option<T>> so that empty containers still encode with the correct element/inner type.

Functions§

decode
Decode bytes to a value (graph-encoded ABI)
decode_with_limits
Decode bytes to a value with custom limits
encode
Encode a value to bytes (graph-encoded ABI)
hash_function
Hash a function signature. Param names are NOT included (just types in order). Result types are included in order.
hash_interface
Hash an interface (includes binding names). Bindings should be in canonical order (sorted by name).
hash_list
Hash a list type: list<T>.
hash_option
Hash an option type: option<T>.
hash_record
Hash a record type (structural - name NOT included). Fields should be in canonical order (sorted by name).
hash_result
Hash a result type: result<T, E>.
hash_tuple
Hash a tuple type: tuple<T1, T2, ...>.
hash_variant
Hash a variant type (structural - name NOT included). Cases should be in canonical order (sorted by name).
parse_value
Parse a value literal string into a Value.