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
- Graph
Buffer - Limits
- Node
- Parse
Error - Parse error with position information.
- Type
Hash - A 256-bit type hash.
- Type
Hasher - Builder for computing type hashes.
Enums§
- AbiError
- Conversion
Error - Error type for Value conversions
- Node
Kind - Value
- A runtime value that can be passed across package boundaries
- Value
Type - Runtime type representation for CGRF v2
Constants§
- HASH_
BOOL - Hash for the
booltype. - HASH_
CHAR - Hash for the
chartype. - HASH_
F32 - Hash for the
f32type. - HASH_
F64 - Hash for the
f64type. - HASH_
FLAGS - Hash for the
flagstype. - HASH_S8
- Hash for the
s8type. - HASH_
S16 - Hash for the
s16type. - HASH_
S32 - Hash for the
s32type. - HASH_
S64 - Hash for the
s64type. - HASH_
SELF_ REF - Placeholder for self-references in recursive types.
- HASH_
STRING - Hash for the
stringtype. - HASH_U8
- Hash for the
u8type. - HASH_
U16 - Hash for the
u16type. - HASH_
U32 - Hash for the
u32type. - HASH_
U64 - Hash for the
u64type.
Traits§
- From
Value - Trait for converting from a Value.
- Graph
Codec - Known
Value Type - Compile-time
ValueTypefor a Rust type. Used byFrom<Vec<T>>andFrom<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.