Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/text"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
ascii |
core/ascii |
text.dodo |
bytes |
core/bytes |
text.dodo |
io |
std/io |
text.dodo |
mem |
core/mem |
text.dodo |
REPLACEMENT
Constant · Source
Unicode scalar values follow Unicode 16.0.0. This package needs no Unicode property tables: trimming/case-independent digits use explicitly ASCII rules.
pub const REPLACEMENT: u32 = 65533
MAX_FLOAT_DIGITS
Constant · Source
pub const MAX_FLOAT_DIGITS: usize = 768
ErrorKind
Enum · Source
pub enum ErrorKind {
InvalidLead, InvalidContinuation, Truncated, InvalidScalar,
OutOfBounds, NotBoundary, BufferFull, EmptyDelimiter,
EmptyNumber, InvalidDigit, InvalidRadix, Overflow, InvalidNumber, TooManyDigits
}
Error
Struct · Source
pub struct Error {
pub kind: ErrorKind
pub position: usize
}
Error.format
Function · Source
Only fixed kind names and numeric metadata; never input or native messages.
pub fn format<F>(&self, output: &mut F) -> void!io.Error
Decoded
Struct · Source
pub struct Decoded {
pub scalar: u32
pub next: usize
}
is_scalar
Function · Source
pub fn is_scalar(value: u32) -> bool
decode
Function · Source
Positions are byte offsets. Truncation reports the missing byte at data.len; malformed continuation reports the offending byte, including range violations.
pub fn decode(data: &[u8], offset: usize) -> Decoded!Error
validate
Function · Source
pub fn validate(data: &[u8]) -> void!Error
decode_replacement
Function · Source
Explicit replacement policy: one U+FFFD per malformed byte, never skips a later valid leading byte. At EOF returns none; no hidden lossy conversion.
pub fn decode_replacement(data: &[u8], offset: usize) -> Option<Decoded>
encoded_len
Function · Source
pub fn encoded_len(scalar: u32) -> usize!Error
encode
Function · Source
Validate scalar and capacity before modifying destination. No partial encoding.
pub fn encode(scalar: u32, destination: &mut[u8]) -> usize!Error
Text
Struct · Source
A validated, borrowed UTF-8 byte sequence; scalar count is not grapheme count. No mutable bytes are exposed, preserving validity for every derived view.
pub struct Text {
// Private implementation fields omitted.
}
Text.new
Function · Source
pub fn new(data: &[u8]) -> Text!Error from(data)
Text.from_str
Function · Source
pub fn from_str(value: &str) -> Text from(value)
Text.as_bytes
Function · Source
pub fn as_bytes(&self) -> &[u8]from(self)
Text.as_str
Function · Source
pub fn as_str(&self) -> &str from(self)
Text.len_bytes
Function · Source
pub fn len_bytes(&self) -> usize
Text.is_empty
Function · Source
pub fn is_empty(&self) -> bool
Text.is_boundary
Function · Source
pub fn is_boundary(&self, offset: usize) -> bool
Text.floor_boundary
Function · Source
pub fn floor_boundary(&self, offset: usize) -> usize!Error
Text.ceil_boundary
Function · Source
pub fn ceil_boundary(&self, offset: usize) -> usize!Error
Text.slice
Function · Source
pub fn slice(&self, start: usize, end: usize) -> Text!Error from(self)
Text.scalars
Function · Source
pub fn scalars(&self) -> Scalars from(self)
Text.len_scalars
Function · Source
pub fn len_scalars(&self) -> usize
Text.byte_offset
Function · Source
Maps a scalar index to a byte boundary, including one-past-the-end.
pub fn byte_offset(&self, scalar_index: usize) -> usize!Error
Text.slice_scalars
Function · Source
pub fn slice_scalars(&self, start: usize, end: usize) -> Text!Error from(self)
Text.equal
Function · Source
pub fn equal(&self, other: &Text) -> bool
Text.starts_with
Function · Source
pub fn starts_with(&self, prefix: &Text) -> bool
Text.ends_with
Function · Source
pub fn ends_with(&self, suffix: &Text) -> bool
Text.find
Function · Source
Exact UTF-8 byte search returns a byte offset; no normalization or folding.
pub fn find(&self, needle: &Text) -> Option<usize>
Text.trim_ascii
Function · Source
pub fn trim_ascii(&self) -> Text from(self)
Text.split
Function · Source
Empty delimiter is rejected. Splitting preserves leading/trailing empty fields. A splitter retains both source and delimiter borrows.
pub fn split(&self, delimiter: &Text) -> Split!Error from(self, delimiter)
Scalar
Struct · Source
pub struct Scalar {
pub value: u32
pub start: usize
pub end: usize
}
Scalars
Struct · Source
pub struct Scalars {
// Private implementation fields omitted.
}
Scalars.next
Function · Source
pub fn next(&mut self) -> Option<Scalar>
Split
Struct · Source
pub struct Split {
// Private implementation fields omitted.
}
Split.next
Function · Source
pub fn next(&mut self) -> Option<Text> from(self)
Builder
Struct · Source
Caller-backed builder. Appends are transactional; views borrow the builder and prevent append/clear while live. Capacity is fixed for its entire lifetime.
pub struct Builder {
// Private implementation fields omitted.
}
Builder.new
Function · Source
pub fn new(storage: &mut[u8]) -> Builder from(storage)
Builder.len_bytes
Function · Source
pub fn len_bytes(&self) -> usize
Builder.capacity
Function · Source
pub fn capacity(&self) -> usize
Builder.clear
Function · Source
pub fn clear(&mut self)
Builder.as_text
Function · Source
pub fn as_text(&self) -> Text from(self)
Builder.append
Function · Source
pub fn append(&mut self, value: &Text) -> void!Error
Builder.push
Function · Source
pub fn push(&mut self, scalar: u32) -> void!Error
parse_u64
Function · Source
Full consumption; no whitespace, separators or implicit radix prefixes.
pub fn parse_u64(data: &[u8], radix: u32) -> u64!Error
parse_i64
Function · Source
pub fn parse_i64(data: &[u8], radix: u32) -> i64!Error
parse_f64
Function · Source
Finite decimal grammar: [+-]?(digits(.digits?)?|.digits)([eE][+-]?digits)? Rejects whitespace, NaN, infinity, hexadecimal notation, and incomplete input. Overflow is recoverable; underflow rounds to subnormal or signed zero.
pub fn parse_f64(data: &[u8]) -> f64!Error
ParseError
Enum · Source
Strict decimal parsing for bounded fields such as ISO 8601 components. Unlike parse_u64, this accepts ASCII digits only: no sign or whitespace.
pub enum ParseError {
Empty, InvalidDigit, Overflow
}
parse_u32_decimal
Function · Source
pub fn parse_u32_decimal(data: &[u8]) -> u32!ParseError