Available on crate feature
text only.Expand description
Textproto (text format) encoding and decoding.
The protobuf text format is a human-readable debug representation:
name: "Alice"
id: 42
address {
street: "1 High St"
city: "London"
}
tags: "a"
tags: "b"It is not a stable wire format — the spec permits implementations to vary whitespace, field ordering, and float formatting. Use binary or JSON for interchange. Textproto is for config files, golden-file tests, and logging.
§Usage
Generated message types implement TextFormat when the text feature
is enabled in codegen. The convenience functions cover the common cases:
ⓘ
use buffa::text::{encode_to_string, decode_from_str};
let s = encode_to_string(&my_msg);
let parsed: MyMsg = decode_from_str(&s)?;For streaming or reuse, use TextEncoder / TextDecoder directly.
§no_std
Fully no_std + alloc. No external dependencies beyond the runtime
crate itself.
Structs§
- Parse
Error - An error encountered while parsing textproto input.
- Text
Decoder - Stateful textproto reader.
- Text
Encoder - Stateful textproto writer.
- Token
- A single textproto token, borrowing from the input.
- Tokenizer
- Stateful textproto tokenizer.
Enums§
- Name
Kind - Secondary classification of a
TokenKind::Nametoken. - Parse
Error Kind - The category of textproto parse error.
- Scalar
Kind - Secondary classification of a
TokenKind::Scalartoken. - Token
Kind - The kind of a textproto token.
- Unescape
Error - Error returned by
unescapeandunescape_str.
Traits§
- Text
Format - Textproto serialization for a
Messagetype.
Functions§
- decode_
from_ str - Decode a message from a textproto string.
- encode_
to_ string - Encode a message as a single-line textproto string.
- encode_
to_ string_ pretty - Encode a message as a multi-line textproto string with 2-space indent.
- escape_
bytes - Write
bytesas a double-quoted textproto string literal tow. - escape_
str - Write
sas a double-quoted textproto string literal tow, preserving multi-byte UTF-8 codepoints as-is. - merge_
from_ str - Merge a textproto string into an existing message.
- unescape
- Unescape a textproto string token — one or more adjacent quoted literals — into a byte vector.
- unescape_
str - Unescape a textproto string token and validate as UTF-8.