Encoding class

Represents the encoding of a zenoh payload.

Uses MIME type strings to describe the encoding format. Provides predefined constants for common types and supports custom MIME types via the constructor.

An encoding marshals into two independent channels at a send site: the mime string and an optional schema. Both are held here as a pure value -- withSchema returns a NEW Encoding rather than setting a schema in place, and the type carries no native dependency (it does not import dart:ffi). Canon's schema setter is invoked in the C shim at send time, not by this type.

Structural equality diverges from wire equality

Equality and hashCode are structural over mimeType and the RAW schema -- exactly the pair that determines the wire -- so == means "these two marshal identically". It does NOT mean "these two are the same encoding on the wire": Encoding('text/plain;utf-8') and Encoding.textPlain.withSchema('utf-8') render identically on the wire and are nonetheless unequal here.

That divergence is deliberate. Wire equality depends on whether the mime string names a well-known id, which requires canon's 53-entry id table and z_encoding_equals -- precisely the native dependency this type keeps out. A pure-Dart == approximating it would be a silent substitution on the very surface this binding exists to make faithful.

The consequence for consumers: an encoding received as 'application/json;my-schema' and rebuilt through Encoding(...) will NOT match a Set or Map key built as Encoding.applicationJson.withSchema('my-schema'). Build both sides of such a lookup the same way.

Annotations
  • @immutable

Constructors

Encoding(String mimeType)
Creates an Encoding with the given mimeType.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
mimeType String
The MIME type string for this encoding.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schema String?
The schema carried by this encoding, or null when there is none.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Renders this encoding the way canon composes one, so display and wire agree.
override
withSchema(String schema) Encoding
Returns a copy of this encoding carrying schema as its schema.

Operators

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

Constants

applicationCbor → const Encoding
A Concise Binary Object Representation (CBOR)-encoded data.
applicationCdr → const Encoding
A Common Data Representation (CDR)-encoded data.
applicationCoapPayload → const Encoding
Constrained Application Protocol (CoAP) data intended for CoAP-to-HTTP and HTTP-to-CoAP proxies.
applicationJavaSerializedObject → const Encoding
A Java serialized object.
applicationJson → const Encoding
A JSON document.
applicationJsonPatchJson → const Encoding
Defines a JSON document structure for expressing a sequence of operations to apply to a JSON document.
applicationJsonpath → const Encoding
A JSONPath defines a string syntax for selecting and extracting JSON values from within a given JSON value.
applicationJsonSeq → const Encoding
A JSON text sequence consists of any number of JSON texts, all encoded in UTF-8.
applicationJwt → const Encoding
A JSON Web Token (JWT).
applicationMp4 → const Encoding
An application-specific MPEG-4 encoded data, either audio or video.
applicationOctetStream → const Encoding
Arbitrary binary data.
applicationOpenmetricsText → const Encoding
An openmetrics data, common used by Prometheus.
applicationProtobuf → const Encoding
A Protocol Buffers message.
applicationPythonSerializedObject → const Encoding
A Python object serialized using pickle.
applicationSoapXml → const Encoding
A SOAP 1.2 message serialized as XML 1.0.
applicationSql → const Encoding
An application-specific SQL query.
applicationXml → const Encoding
An XML file intended to be consumed by an application..
applicationXWwwFormUrlencoded → const Encoding
An encoded a list of tuples, each consisting of a name and a value.
applicationYaml → const Encoding
YAML data intended to be consumed by an application.
applicationYang → const Encoding
A YANG-encoded data commonly used by the Network Configuration Protocol (NETCONF).
audioAac → const Encoding
A MPEG-4 Advanced Audio Coding (AAC) media.
audioFlac → const Encoding
A Free Lossless Audio Codec (FLAC) media.
audioMp4 → const Encoding
An audio codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority.
audioOgg → const Encoding
An Ogg-encapsulated audio stream.
audioVorbis → const Encoding
A Vorbis-encoded audio stream.
imageBmp → const Encoding
A BitMap (BMP) image.
imageGif → const Encoding
A Graphics Interchange Format (GIF) image.
imageJpeg → const Encoding
A JPEG image.
imagePng → const Encoding
A PNG image.
imageWebp → const Encoding
A Web Portable (WebP) image.
textCss → const Encoding
A CSS file.
textCsv → const Encoding
Comma-separated values.
textHtml → const Encoding
An HTML document.
textJavascript → const Encoding
A JavaScript file.
textJson → const Encoding
JSON data intended to be human readable.
textJson5 → const Encoding
JSON5 encoded data that are human readable.
textMarkdown → const Encoding
A MarkDown file.
textPlain → const Encoding
Plain text.
textXml → const Encoding
An XML file that is human readable.
textYaml → const Encoding
YAML data intended to be human readable.
videoH261 → const Encoding
A h261-encoded video stream.
videoH263 → const Encoding
A h263-encoded video stream.
videoH264 → const Encoding
A h264-encoded video stream.
videoH265 → const Encoding
A h265-encoded video stream.
videoH266 → const Encoding
A h266-encoded video stream.
videoMp4 → const Encoding
A video codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority.
videoOgg → const Encoding
An Ogg-encapsulated video stream.
videoRaw → const Encoding
An uncompressed, studio-quality video stream.
videoVp8 → const Encoding
A VP8-encoded video stream.
videoVp9 → const Encoding
A VP9-encoded video stream.
zenohBytes → const Encoding
Opaque bytes with no interpretation -- zenoh's default encoding.
zenohSerialized → const Encoding
Zenoh serialized data. This encoding supposes that the payload was created with serialization functions. The schema field may contain the details of serialziation format.
zenohString → const Encoding
A UTF-8 string.