pub struct EncodeSet(/* private fields */);Expand description
A set of bytes that must be percent-encoded: a 256-bit bitmap.
encode always encodes bytes above 0x7F, whatever the set says.
§Examples
use parse_net::pct::EncodeSet;
let path = EncodeSet::CONTROLS_AND_NON_ASCII.add(b' ').add(b'#').add(b'?');
assert!(path.contains(b'#') && !path.contains(b'/'));
assert!(!path.remove(b'#').contains(b'#'));Implementations§
Source§impl EncodeSet
impl EncodeSet
Sourcepub const CONTROLS_AND_NON_ASCII: Self
pub const CONTROLS_AND_NON_ASCII: Self
C0 controls, DEL, and 0x80 to 0xFF.
§Examples
use parse_net::pct::EncodeSet;
let s = EncodeSet::CONTROLS_AND_NON_ASCII;
assert!(s.contains(b'\n') && s.contains(0x7f) && s.contains(0xe9));
assert!(!s.contains(b' ') && !s.contains(b'%'));Sourcepub const ATTR_CHAR_COMPLEMENT: Self
pub const ATTR_CHAR_COMPLEMENT: Self
Every byte that is not an attr-char (RFC 8187 section 3.2.1).
§Examples
use parse_net::pct::EncodeSet;
let s = EncodeSet::ATTR_CHAR_COMPLEMENT;
assert!(s.contains(b' ') && s.contains(b'%') && s.contains(b'\''));
assert!(!s.contains(b'a') && !s.contains(b'~'));Sourcepub const SF_DISPLAY: Self
pub const SF_DISPLAY: Self
%, ", and every byte outside 0x20 to 0x7E (RFC 9651 section 4.1.11).
§Examples
use parse_net::pct::EncodeSet;
let s = EncodeSet::SF_DISPLAY;
assert!(s.contains(b'%') && s.contains(b'"') && s.contains(0x7f));
assert!(!s.contains(b' ') && !s.contains(b'~'));Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
The empty set (only bytes above 0x7F are then encoded).
§Examples
use parse_net::pct::{encoded_len, EncodeSet};
let none = EncodeSet::empty();
assert!(!none.contains(b'%'));
assert_eq!(encoded_len(b"a b", &none), 3);
assert_eq!(encoded_len(&[0xff], &none), 3);Sourcepub const fn add(self, b: u8) -> Self
pub const fn add(self, b: u8) -> Self
The set with b added.
§Examples
use parse_net::pct::EncodeSet;
let s = EncodeSet::empty().add(b'/');
assert!(s.contains(b'/') && !s.contains(b'?'));Trait Implementations§
impl Copy for EncodeSet
impl Eq for EncodeSet
impl StructuralPartialEq for EncodeSet
Auto Trait Implementations§
impl Forget for EncodeSet
impl Freeze for EncodeSet
impl RefUnwindSafe for EncodeSet
impl Send for EncodeSet
impl Sync for EncodeSet
impl Unpin for EncodeSet
impl UnsafeUnpin for EncodeSet
impl UnwindSafe for EncodeSet
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