pub struct KxCfRef<'a> { /* private fields */ }Expand description
Zero-copy view over the k elements of a KxCf array (each element is a
fixed-width f-byte string, no length prefix).
Elements are decoded with the same rule as CnRef::as_str and can be
iterated directly:
use rust_stdf::KxCfRef;
let raw = [b'A', b'B', b'C', b'D']; // two fixed 2-byte elements: "AB", "CD"
let kx = KxCfRef::new(&raw, 0, 2, 2);
for s in &kx {
println!("{s}");
}Implementations§
Source§impl<'a> KxCfRef<'a>
impl<'a> KxCfRef<'a>
Sourcepub fn new(raw: &'a [u8], start: usize, k: usize, f: usize) -> Self
pub fn new(raw: &'a [u8], start: usize, k: usize, f: usize) -> Self
Construct a view over k fixed f-byte elements starting at byte
offset start.
Normally obtained from a generated *View getter; only needed when
parsing a known raw layout directly.
Sourcepub fn get_str(&self, i: usize) -> Option<Cow<'a, str>>
pub fn get_str(&self, i: usize) -> Option<Cow<'a, str>>
Decoded i-th element; None when i is out of range.
Valid UTF-8 payloads are borrowed zero-copy; other payloads are decoded
byte → char (Latin-1) into an owned String.
Sourcepub fn get_bytes(&self, i: usize) -> Option<&'a [u8]>
pub fn get_bytes(&self, i: usize) -> Option<&'a [u8]>
Raw payload bytes of the i-th element; None when i is out of
range or lies past the end of the buffer.
Sourcepub fn iter(&self) -> KxCfRefIter<'a> ⓘ
pub fn iter(&self) -> KxCfRefIter<'a> ⓘ
Iterator over the decoded elements, one pass.
Trait Implementations§
impl<'a> Copy for KxCfRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for KxCfRef<'a>
impl<'a> RefUnwindSafe for KxCfRef<'a>
impl<'a> Send for KxCfRef<'a>
impl<'a> Sync for KxCfRef<'a>
impl<'a> Unpin for KxCfRef<'a>
impl<'a> UnsafeUnpin for KxCfRef<'a>
impl<'a> UnwindSafe for KxCfRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more