pub struct CStringLiteralCodec;Expand description
Encodes and decodes byte-oriented C string literal fragments.
This codec is intended for textual formats that embed byte sequences with C
escapes, such as PK\003\004 or \xd0\xcf. It decodes into raw bytes and
does not require surrounding quotes.
Its low-level Codec<Value = u8, Unit = u8> implementation handles one
raw byte or one C escape fragment. Whole-fragment iteration remains part of
the owned encode and decode helpers.
Implementations§
Source§impl CStringLiteralCodec
impl CStringLiteralCodec
Sourcepub fn decode(&self, text: &str) -> MiscCodecResult<Vec<u8>>
pub fn decode(&self, text: &str) -> MiscCodecResult<Vec<u8>>
Decodes a C string literal fragment into bytes.
§Parameters
text: C string literal fragment without surrounding quotes.
§Returns
Decoded raw bytes.
§Errors
Returns MiscCodecError::InvalidEscape for malformed escape
sequences, MiscCodecError::InvalidDigit for malformed
fixed-width numeric escapes,
and MiscCodecError::InvalidCharacter for unsupported raw source
characters.
Trait Implementations§
Source§impl Clone for CStringLiteralCodec
impl Clone for CStringLiteralCodec
Source§fn clone(&self) -> CStringLiteralCodec
fn clone(&self) -> CStringLiteralCodec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Codec for CStringLiteralCodec
impl Codec for CStringLiteralCodec
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Returns the shortest representation length for one byte.
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Returns the longest supported universal escape length for one byte.
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u8, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u8, NonZeroUsize), Self::DecodeError>
Decodes one raw byte or one C escape fragment.
Source§unsafe fn encode_unchecked(
&self,
value: &u8,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u8, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Encodes one byte as a raw byte or C escape fragment.
Source§type DecodeError = MiscCodecError
type DecodeError = MiscCodecError
Source§type EncodeError = MiscCodecError
type EncodeError = MiscCodecError
impl Copy for CStringLiteralCodec
Source§impl Debug for CStringLiteralCodec
impl Debug for CStringLiteralCodec
Source§impl Default for CStringLiteralCodec
impl Default for CStringLiteralCodec
Source§fn default() -> CStringLiteralCodec
fn default() -> CStringLiteralCodec
impl Eq for CStringLiteralCodec
Source§impl PartialEq for CStringLiteralCodec
impl PartialEq for CStringLiteralCodec
Source§fn eq(&self, other: &CStringLiteralCodec) -> bool
fn eq(&self, other: &CStringLiteralCodec) -> bool
self and other values to be equal, and is used by ==.