pub struct DisplayString<'a> { /* private fields */ }Expand description
A Display String: the percent-encoded text between the quotes, validated as UTF-8 during the parse.
§Examples
use parse_net::sfv::{self, BareItem};
let BareItem::DisplayString(d) = sfv::parse_item(b"%\"caf%c3%a9\"")?.bare else { unreachable!() };
assert_eq!(d.raw(), b"caf%c3%a9");
assert_eq!(d.decoded_len(), 5);Implementations§
Source§impl<'a> DisplayString<'a>
impl<'a> DisplayString<'a>
Sourcepub const fn raw(&self) -> &'a [u8] ⓘ
pub const fn raw(&self) -> &'a [u8] ⓘ
The text as sent, %xx triples included.
§Examples
use parse_net::sfv::{self, BareItem};
let BareItem::DisplayString(d) = sfv::parse_item(b"%\"50%25\"")?.bare else { unreachable!() };
assert_eq!(d.raw(), b"50%25");Sourcepub fn decoded_len(&self) -> usize
pub fn decoded_len(&self) -> usize
The length of the decoded UTF-8 text.
§Examples
use parse_net::sfv::{self, BareItem};
let BareItem::DisplayString(d) = sfv::parse_item(b"%\"caf%c3%a9\"")?.bare else { unreachable!() };
assert_eq!(d.decoded_len(), 5);Sourcepub fn decode_into<'b>(&self, out: &'b mut [u8]) -> Result<&'b str, ParseError>
pub fn decode_into<'b>(&self, out: &'b mut [u8]) -> Result<&'b str, ParseError>
Writes the decoded text into out and returns it.
§Errors
ErrorKind::BufferTooSmall; nothing is written.
§Examples
use parse_net::sfv::{self, BareItem};
let BareItem::DisplayString(d) = sfv::parse_item(b"%\"caf%c3%a9\"")?.bare else { unreachable!() };
let mut buf = [0u8; 8];
assert_eq!(d.decode_into(&mut buf)?, "caf\u{e9}");Trait Implementations§
Source§impl<'a> Clone for DisplayString<'a>
impl<'a> Clone for DisplayString<'a>
impl<'a> Copy for DisplayString<'a>
Source§impl<'a> Debug for DisplayString<'a>
impl<'a> Debug for DisplayString<'a>
impl<'a> Eq for DisplayString<'a>
Source§impl<'a> Hash for DisplayString<'a>
impl<'a> Hash for DisplayString<'a>
Source§impl<'a> PartialEq for DisplayString<'a>
impl<'a> PartialEq for DisplayString<'a>
impl<'a> StructuralPartialEq for DisplayString<'a>
Auto Trait Implementations§
impl<'a> Forget for DisplayString<'a>
impl<'a> Freeze for DisplayString<'a>
impl<'a> RefUnwindSafe for DisplayString<'a>
impl<'a> Send for DisplayString<'a>
impl<'a> Sync for DisplayString<'a>
impl<'a> Unpin for DisplayString<'a>
impl<'a> UnsafeUnpin for DisplayString<'a>
impl<'a> UnwindSafe for DisplayString<'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