pub struct PercentCodec;Expand description
Encodes and decodes percent-encoded UTF-8 text.
Its low-level Codec<Value = u8, Unit = u8> implementation converts one
byte to either one unreserved ASCII unit or a %XX escape. UTF-8 validation
remains part of the owned decode helper.
Implementations§
Source§impl PercentCodec
impl PercentCodec
Sourcepub fn decode(&self, text: &str) -> MiscCodecResult<String>
pub fn decode(&self, text: &str) -> MiscCodecResult<String>
Decodes percent-encoded UTF-8 text.
§Parameters
text: Percent-encoded text.
§Returns
Decoded UTF-8 text.
§Errors
Returns MiscCodecError when a percent escape is malformed or decoded
bytes are not valid UTF-8.
Trait Implementations§
Source§impl Clone for PercentCodec
impl Clone for PercentCodec
Source§fn clone(&self) -> PercentCodec
fn clone(&self) -> PercentCodec
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Codec for PercentCodec
impl Codec for PercentCodec
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 %XX representation 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 %XX escape.
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 using percent encoding.
Source§type DecodeError = MiscCodecError
type DecodeError = MiscCodecError
Error reported when decoding malformed units.
Source§type EncodeError = MiscCodecError
type EncodeError = MiscCodecError
Error reported when encoding an unsupported value.
impl Copy for PercentCodec
Source§impl Debug for PercentCodec
impl Debug for PercentCodec
Source§impl Default for PercentCodec
impl Default for PercentCodec
Source§fn default() -> PercentCodec
fn default() -> PercentCodec
Returns the “default value” for a type. Read more
impl Eq for PercentCodec
Source§impl PartialEq for PercentCodec
impl PartialEq for PercentCodec
Source§fn eq(&self, other: &PercentCodec) -> bool
fn eq(&self, other: &PercentCodec) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PercentCodec
Source§impl ValueDecoder<str> for PercentCodec
impl ValueDecoder<str> for PercentCodec
Auto Trait Implementations§
impl Freeze for PercentCodec
impl RefUnwindSafe for PercentCodec
impl Send for PercentCodec
impl Sync for PercentCodec
impl Unpin for PercentCodec
impl UnsafeUnpin for PercentCodec
impl UnwindSafe for PercentCodec
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