worker_route::http

Struct HttpHeaders

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

A wrapper for worker::Headers with additional methods.

This comes with two additional method which are self.len() and self.is_empty().

Implementations§

Source§

impl HttpHeaders

Source

pub fn new() -> Self

Source

pub fn get(&self, name: &HeaderName) -> Option<String>

Returns all the values of a header within a Headers object with a given name.

§Panics

Panics if HeaderName is constructed from using the method from_static and the static string is an invalid header or contains spaces.

Eg: Header contains invalid header’s name or spaces.

Source

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

Returns a boolean stating whether a Headers object contains a certain header.

§Panics

Panics if HeaderName is constructed from using the method from_static and the static string is an invalid header or contains spaces.

Eg: Header contains invalid header’s name or spaces.

Source

pub fn len(&self) -> usize

Returns the number of elements in the headers.

Source

pub fn is_empty(&self) -> bool

Returns true if the headers contain no elements.

Source

pub fn append( &mut self, name: &HeaderName, value: &HeaderValue, ) -> Result<(), Error>

Append a header, keeping any that were set with an equivalent field name.

§Errors

Errors are returned if the header name or value is invalid (e.g. contains spaces)

§Panics

Panics if HeaderName or HeaderValue is constructed from using the method from_static and the static string is an invalid header or contains spaces.

Eg: Header contains invalid header’s name or spaces.

Source

pub fn set( &mut self, name: &HeaderName, value: &HeaderValue, ) -> Result<(), Error>

Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.

§Errors

Errors are returned if the header name or value is invalid (e.g. contains spaces)

§Panics

Panics if HeaderName or HeaderValue is constructed from using the method from_static and the static string is an invalid header or contains spaces.

Eg: Header contains invalid header’s name or spaces.

Source

pub fn delete(&mut self, name: &HeaderName) -> Result<(), Error>

Deletes a header from a Headers object.

§Errors

Errors are returned if the header name or value is invalid (e.g. contains spaces) or if the JS Headers object’s guard is immutable (e.g. for an incoming request)

§Panics

Panics if HeaderName is constructed from using the method from_static and the static string is an invalid header or contains spaces.

Eg: Header contains invalid header’s name or spaces.

Source

pub fn entries( &self, ) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)>

Returns an iterator allowing to go through all key/value pairs contained in this object.

Source

pub fn keys(&self) -> impl Iterator<Item = String>

Returns an iterator allowing you to go through all keys of the key/value pairs contained in this object.

Source

pub fn values(&self) -> impl Iterator<Item = String>

Returns an iterator allowing you to go through all values of the key/value pairs contained in this object.

Methods from Deref<Target = Headers>§

Source

pub fn get(&self, name: &str) -> Result<Option<String>, Error>

Returns all the values of a header within a Headers object with a given name. Returns an error if the name is invalid (e.g. contains spaces)

Source

pub fn has(&self, name: &str) -> Result<bool, Error>

Returns a boolean stating whether a Headers object contains a certain header. Returns an error if the name is invalid (e.g. contains spaces)

Source

pub fn append(&mut self, name: &str, value: &str) -> Result<(), Error>

Returns an error if the name is invalid (e.g. contains spaces)

Source

pub fn set(&mut self, name: &str, value: &str) -> Result<(), Error>

Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist. Returns an error if the name is invalid (e.g. contains spaces)

Source

pub fn delete(&mut self, name: &str) -> Result<(), Error>

Deletes a header from a Headers object. Returns an error if the name is invalid (e.g. contains spaces) or if the JS Headers object’s guard is immutable (e.g. for an incoming request)

Source

pub fn entries( &self, ) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)>

Returns an iterator allowing to go through all key/value pairs contained in this object.

Source

pub fn keys(&self) -> impl Iterator<Item = String>

Returns an iterator allowing you to go through all keys of the key/value pairs contained in this object.

Source

pub fn values(&self) -> impl Iterator<Item = String>

Returns an iterator allowing you to go through all values of the key/value pairs contained in this object.

Trait Implementations§

Source§

impl Clone for HttpHeaders

Source§

fn clone(&self) -> HttpHeaders

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpHeaders

Source§

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

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

impl Default for HttpHeaders

Source§

fn default() -> HttpHeaders

Returns the “default value” for a type. Read more
Source§

impl Deref for HttpHeaders

Source§

type Target = Headers

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for HttpHeaders

Source§

fn deref_mut(&mut self) -> &mut Headers

Mutably dereferences the value.
Source§

impl From<&Headers> for HttpHeaders

Source§

fn from(headers: &Headers) -> Self

Converts to this type from the input type.
Source§

impl From<&HttpHeaders> for Headers

Source§

fn from(headers: &HttpHeaders) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut HttpHeaders> for &'a mut Headers

Source§

fn from(headers: &'a mut HttpHeaders) -> Self

Converts to this type from the input type.
Source§

impl From<HttpHeaders> for Headers

Source§

fn from(headers: HttpHeaders) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for &HttpHeaders

Source§

type Item = (String, String)

The type of the elements being iterated over.
Source§

type IntoIter = Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T