pub enum Element<'a> {
Int(i64),
Float(f64),
Str(&'a [u8]),
Short(Short),
}Expand description
What is stored at one index, in whichever form it was worth keeping.
Handing back the stored form rather than bytes is Y18: a value that went in
as 12345 is held as an i64 and formatted once, into the reply buffer, at
the moment the reply is built. Use Element::text to get the bytes when
the caller has nowhere better to put them.
Variants§
Int(i64)
A value that was written as an integer and is held as one.
Float(f64)
A value that was written as a decimal and round trips as a double.
Str(&'a [u8])
A string long enough to live in the array’s blob, borrowed from it.
Short(Short)
A string of seven bytes or fewer, which was packed into the word and so has nowhere to be borrowed from.
Implementations§
Source§impl<'a> Element<'a>
impl<'a> Element<'a>
Sourcepub fn text<'b>(&'b self, buf: &'b mut [u8; 34]) -> &'b [u8] ⓘwhere
'a: 'b,
pub fn text<'b>(&'b self, buf: &'b mut [u8; 34]) -> &'b [u8] ⓘwhere
'a: 'b,
The bytes a client would see, written into buf if they are not stored
anywhere already.
A blob string is already bytes and comes back borrowed with buf
untouched. Everything else has to be written somewhere, and it goes into
the caller’s stack buffer rather than a Vec, because the caller needs
the length before it can write the bulk header and a shard thread that
allocates aborts.