ZSerializer class

A zenoh serializer for building structured payloads.

Wraps ze_owned_serializer_t. Call finish to produce a ZBytes, or dispose to release native resources without finishing.

Declared widths: integer widths reject, floating widths round

Every method here names the native width it writes. For the integer widths narrower than 64 bits -- serializeUint8, serializeUint16, serializeUint32, serializeInt8, serializeInt16, serializeInt32 -- a value outside that width's domain throws an ArgumentError naming the domain, raised before any native call is made. It is never truncated into range.

For the unsigned widths this is convention CONV-4(c) applied, not a new rule: "The value is carried full-width -- no silent truncation; a narrower native width (uint8_t) gets an explicit Dart-side range guard naming the domain." CONV-4's scope is parameters marshalled into size_t/uintN_t, so the signed widths fall outside it and take the same rule for their own separate reason: shipping two contradictory domain policies on one surface is worse than extending one policy across it.

serializeFloat (f64 narrowed to f32) does not reject. An integer width has an exactly-representable domain, so a value outside it is a caller error; a binary floating width has no such domain -- every finite f64 has a defined nearest binary32 under IEEE-754, which is a specified rounding rather than a wrap. Canon's own ze_serializer_serialize_float(float) performs the identical narrowing at the ABI. So float documents and pins its narrowing where the integer widths reject.

serializeUint64, serializeInt64 and serializeDouble are unguarded: their domains are Dart's own. A serializeUint64 argument above 2^63 is carried as its bit-exact two's complement pattern -- the only Dart-representable form, and not a transform.

This object holds a native handle, so it cannot cross an isolate boundary: a copy would share this one's native address while carrying its own fresh disposal flag, and the second release would be a use-after-free. Sending it throws ArgumentError naming the class.

It carries a NativeFinalizer safety net: if it is dropped without an explicit release, its native resources are reclaimed when the object is collected. ⛔ The net is not a substitute for releasing it explicitly — a finalizer runs at an unpredictable time, or not at all if the program exits first.

Implemented types

Constructors

ZSerializer()
Creates an empty serializer.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Releases native resources held by this serializer.
finish() ZBytes
Finishes the serializer and returns the produced ZBytes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serializeBool(bool value) → void
Serializes a bool value.
serializeBytes(Uint8List value) → void
Serializes a byte buffer.
serializeDouble(double value) → void
Serializes a double value.
serializeFloat(double value) → void
Serializes a float value, narrowing the f64 value to binary32.
serializeInt16(int value) → void
Serializes an int16 value.
serializeInt32(int value) → void
Serializes an int32 value.
serializeInt64(int value) → void
Serializes an int64 value.
serializeInt8(int value) → void
Serializes an int8 value.
serializeSequenceLength(int length) → void
Serializes a sequence length header.
serializeString(String value) → void
Serializes a UTF-8 string value.
serializeUint16(int value) → void
Serializes a uint16 value.
serializeUint32(int value) → void
Serializes a uint32 value.
serializeUint64(int value) → void
Serializes a uint64 value.
serializeUint8(int value) → void
Serializes a uint8 value.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited