Skip to main content

Module string

Module string 

Source
Expand description

UTF-8 strings and Kafka’s fixed/compact length-prefixed encodings.

KafkaString is backed by Bytes so decoded messages can borrow from the frame buffer without copying.

Kafka uses four string shapes:

VariantLength encoding
read_string / write_stringi16
read_compact_string / …unsigned varint of len + 1
read_nullable_string / …i16 (-1 = null)
read_compact_nullable_stringvarint (0 = null)

Re-exports§

pub use self::error::StringError;
pub use self::error::StringErrorKind;

Modules§

error
Error types for crate::string.

Structs§

KafkaString
A Kafka protocol string backed by Bytes for zero-copy access.

Functions§

compact_nullable_string_len
Encoded length of a nullable compact Kafka string.
compact_string_len
Encoded length of a compact Kafka string.
nullable_string_len
Encoded length of a nullable non-flexible Kafka string.
read_compact_nullable_string
Read a nullable compact Kafka string (unsigned varint, 0 = null).
read_compact_string
Read a compact Kafka string (unsigned varint of len + 1).
read_nullable_string
Read a nullable non-flexible Kafka string (i16, -1 = null).
read_string
Read a non-flexible Kafka string (i16 length prefix).
string_len
Encoded length of a non-flexible Kafka string (i16 length prefix).
write_compact_nullable_string
Write a nullable compact Kafka string (unsigned varint, 0 = null).
write_compact_string
Write a compact Kafka string (unsigned varint of len + 1).
write_nullable_string
Write a nullable non-flexible Kafka string (i16, -1 = null).
write_string
Write a non-flexible Kafka string (i16 length prefix).

Type Aliases§

Result
Result alias for string read operations.