pub struct OwnedString { /* private fields */ }Expand description
Independently owned UTF-8 text with retained capacity accounting.
Only valid UTF-8 may be appended; raw mutable bytes are never exposed.
Borrowing as str uses safe UTF-8 validation and admits its scan first.
This avoids an additional unchecked conversion outside the allocator adapter.
Implementations§
Source§impl OwnedString
impl OwnedString
Sourcepub fn as_str(&self, execution: &Memory) -> Result<&str, MemoryError>
pub fn as_str(&self, execution: &Memory) -> Result<&str, MemoryError>
Borrows the text without copying, charging safe UTF-8 validation to the current execution domain, independently of the retained storage domain.
§Panics
Panics if the private UTF-8 invariant is violated. Safe construction and append operations preserve that invariant.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The UTF-8 bytes, as an allocation-free view; callers account traversal.
Sourcepub fn try_push_str(&mut self, text: &str) -> Result<(), MemoryError>
pub fn try_push_str(&mut self, text: &str) -> Result<(), MemoryError>
Appends valid UTF-8 after admitting capacity and copying work.
Sourcepub fn try_push(&mut self, character: char) -> Result<(), MemoryError>
pub fn try_push(&mut self, character: char) -> Result<(), MemoryError>
Appends one scalar using a fixed stack buffer, without hidden allocation.
Sourcepub fn try_copy(&self) -> Result<Self, MemoryError>
pub fn try_copy(&self) -> Result<Self, MemoryError>
Creates an independently charged copy in the same domain.