pub struct DbStr<'a>(/* private fields */);Expand description
A borrowed or owned run of bytes from a file.
Not a string. LCF records no encoding, so this crate does not pretend to know one (see the crate docs). The bytes are whatever the authoring machine’s codepage produced: commonly Shift-JIS or CP1252, but the format does not say which.
Borrows from the input until into_owned, so loading copies no text.
Implementations§
Source§impl<'a> DbStr<'a>
impl<'a> DbStr<'a>
Sourcepub const fn from_bytes(bytes: &'a [u8]) -> Self
pub const fn from_bytes(bytes: &'a [u8]) -> Self
Borrow a run of bytes.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the field is empty. Empty is the default for every string field, so the writer elides it.
Sourcepub fn into_owned(self) -> DbStr<'static>
pub fn into_owned(self) -> DbStr<'static>
Detach from the input buffer.
Trait Implementations§
impl<'a> Eq for DbStr<'a>
Source§impl<'a> LcfField<'a> for DbStr<'a>
impl<'a> LcfField<'a> for DbStr<'a>
Source§fn field_default(_engine: Engine) -> Self
fn field_default(_engine: Engine) -> Self
The value this field holds when its chunk is absent and the schema gives no explicit
default. Read more
Source§fn read(
data: &'a [u8],
_ctx: &mut Ctx<'_>,
_owner: &'static str,
_id: u32,
) -> Self
fn read( data: &'a [u8], _ctx: &mut Ctx<'_>, _owner: &'static str, _id: u32, ) -> Self
Decode from a chunk payload sliced to exactly this field’s bytes. Read more
Source§fn lcf_size(&self, _engine: Engine) -> u32
fn lcf_size(&self, _engine: Engine) -> u32
Encoded length in bytes, which the two-pass writer emits as the chunk’s length prefix.
Source§fn element_count(&self) -> u32
fn element_count(&self) -> u32
Number of elements, for array-like fields. Read more
Source§fn write<S: Sink>(&self, sink: &mut S, _engine: Engine) -> Result<(), S::Error>
fn write<S: Sink>(&self, sink: &mut S, _engine: Engine) -> Result<(), S::Error>
Append the encoded payload. Read more
Source§fn lcf_differs(&self, other: &Self) -> boolwhere
Self: PartialEq,
fn lcf_differs(&self, other: &Self) -> boolwhere
Self: PartialEq,
Whether
self differs from other in its written form; the writer elides a field equal to
its default. Plain !=, except floats compare by bits: -0.0 == 0.0, so != would drop a
stored -0.0 and break the round trip.Source§impl<'a> Ord for DbStr<'a>
impl<'a> Ord for DbStr<'a>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<'a> PartialOrd for DbStr<'a>
impl<'a> PartialOrd for DbStr<'a>
impl<'a> StructuralPartialEq for DbStr<'a>
Auto Trait Implementations§
impl<'a> Freeze for DbStr<'a>
impl<'a> RefUnwindSafe for DbStr<'a>
impl<'a> Send for DbStr<'a>
impl<'a> Sync for DbStr<'a>
impl<'a> Unpin for DbStr<'a>
impl<'a> UnsafeUnpin for DbStr<'a>
impl<'a> UnwindSafe for DbStr<'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