pub struct FieldValue(/* private fields */);Expand description
The value of one field line.
Bytes rather than a str: RFC 9110 §5.5 admits obs-text (%x80-FF) into a
field value, so one is not necessarily UTF-8. The single place this server
reads a value as text – credentials – asks for it with Self::to_str and
says what it does when the answer is no.
Implementations§
Source§impl FieldValue
impl FieldValue
Sourcepub fn from_static(value: &'static str) -> Self
pub fn from_static(value: &'static str) -> Self
Wraps a value this server authored.
§Panics
On an octet no field value may carry. The bound to 'static is what
makes that acceptable: the argument is a literal in this tree, so a panic
here is a bug found by the first test that sends the field, never
something a peer can provoke.
Sourcepub fn parse(value: &[u8]) -> Option<Self>
pub fn parse(value: &[u8]) -> Option<Self>
Reads a value that arrived from a peer, or one built at runtime.
None for an octet that may not appear in a field value; RFC 9114 §10.3
makes that a malformed message, and super::stream is where it becomes
one.
The accepted set is VCHAR (%x21-7E), obs-text (%x80-FF), SP and HTAB
– so CR, LF, NUL, every other control character and DEL are refused.
RFC 9110 §5.5’s field-content additionally forbids a leading or
trailing SP or HTAB, and that placement rule is deliberately not enforced
here: §10.3’s concern is the three characters that would be exploited by
an intermediary translating the message, all three of which are refused,
and refusing a value with a stray leading space would turn a request that
every other HTTP/3 implementation accepts into a stream error.
Trait Implementations§
Source§impl Clone for FieldValue
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FieldValue
impl Debug for FieldValue
impl Eq for FieldValue
Source§impl PartialEq for FieldValue
impl PartialEq for FieldValue
Source§fn eq(&self, other: &FieldValue) -> bool
fn eq(&self, other: &FieldValue) -> bool
self and other values to be equal, and is used by ==.