Struct Fields

Source
pub struct Fields { /* private fields */ }
Expand description

This following block defines the fields resource which corresponds to HTTP standard Fields. Fields are a common representation used for both Headers and Trailers.

A fields may be mutable or immutable. A fields created using the constructor, from-list, or clone will be mutable, but a fields resource given by other means (including, but not limited to, incoming-request.headers, outgoing-request.headers) might be be immutable. In an immutable fields, the set, append, and delete operations will fail with header-error.immutable.

Implementations§

Source§

impl Fields

Source

pub fn new() -> Fields

Construct an empty HTTP Fields.

The resulting fields is mutable.

Source§

impl Fields

Source

pub fn from_list(entries: &[(String, Vec<u8>)]) -> Result<Fields, HeaderError>

Construct an HTTP Fields.

The resulting fields is mutable.

The list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.

The tuple is a pair of the field name, represented as a string, and Value, represented as a list of bytes.

An error result will be returned if any field-name or field-value is syntactically invalid, or if a field is forbidden.

Source§

impl Fields

Source

pub fn get(&self, name: &String) -> Vec<Vec<u8>>

Get all of the values corresponding to a name. If the name is not present in this fields or is syntactically invalid, an empty list is returned. However, if the name is present but empty, this is represented by a list with one or more empty field-values present.

Source§

impl Fields

Source

pub fn has(&self, name: &String) -> bool

Returns true when the name is present in this fields. If the name is syntactically invalid, false is returned.

Source§

impl Fields

Source

pub fn set(&self, name: &String, value: &[Vec<u8>]) -> Result<(), HeaderError>

Set all of the values for a name. Clears any existing values for that name, if they have been set.

Fails with header-error.immutable if the fields are immutable.

Fails with header-error.invalid-syntax if the field-name or any of the field-values are syntactically invalid.

Source§

impl Fields

Source

pub fn delete(&self, name: &String) -> Result<(), HeaderError>

Delete all values for a name. Does nothing if no values for the name exist.

Fails with header-error.immutable if the fields are immutable.

Fails with header-error.invalid-syntax if the field-name is syntactically invalid.

Source§

impl Fields

Source

pub fn append(&self, name: &String, value: &Vec<u8>) -> Result<(), HeaderError>

Append a value for a name. Does not change or delete any existing values for that name.

Fails with header-error.immutable if the fields are immutable.

Fails with header-error.invalid-syntax if the field-name or field-value are syntactically invalid.

Source§

impl Fields

Source

pub fn entries(&self) -> Vec<(String, Vec<u8>)>

Retrieve the full set of names and values in the Fields. Like the constructor, the list represents each name-value pair.

The outer list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.

The names and values are always returned in the original casing and in the order in which they will be serialized for transport.

Source§

impl Fields

Source

pub fn clone(&self) -> Fields

Make a deep copy of the Fields. Equivalent in behavior to calling the fields constructor on the return value of entries. The resulting fields is mutable.

Trait Implementations§

Source§

impl Debug for Fields

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl TryFrom<Fields> for HeaderMap

Source§

impl TryFrom<HeaderMap> for Fields

Source§

type Error = HeaderError

Source§

fn try_from(headers: HeaderMap) -> Result<Self, Self::Error>

Auto Trait Implementations§

§

impl !Freeze for Fields

§

impl RefUnwindSafe for Fields

§

impl Send for Fields

§

impl Sync for Fields

§

impl Unpin for Fields

§

impl UnwindSafe for Fields

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(v: T) -> U

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

Source§

fn try_into(v: T) -> Result<U, <T as TryInto<U>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.