Skip to main content

Header

Struct Header 

Source
pub struct Header {
    pub description: Option<String>,
    pub required: Option<bool>,
    pub deprecated: Option<bool>,
    pub extensions: Extensions,
    /* private fields */
}
Expand description

A response header, or a header used by an Encoding.

This is a Parameter Object without name and in, and without allowEmptyValue, which the specification refuses a header. Like a parameter it holds one HeaderShape and one Examples.

Fields§

§description: Option<String>

A description of the header. CommonMark syntax may be used.

§required: Option<bool>

Whether the header is mandatory.

§deprecated: Option<bool>

Whether the header is deprecated.

§extensions: Extensions

Specification extensions.

Implementations§

Source§

impl Header

Source

pub fn new(schema: Schema) -> Self

Creates a header described by a schema.

Source

pub fn with_content(media_type: impl Into<String>, value: MediaType) -> Self

Creates a header described by one media type.

Source

pub fn shape(&self) -> &HeaderShape

How this header’s value is described.

Source

pub fn shape_mut(&mut self) -> &mut HeaderShape

The same, mutably.

Handing out &mut costs nothing here: every HeaderShape is a valid description, so there is no combination a caller could reach by editing one that it could not reach by building one.

Source

pub fn schema(&self) -> Option<&Schema>

The schema, when this header is described by one.

Source

pub fn content(&self) -> Option<(&str, &MediaType)>

The media type and its description, when this header uses content.

Source

pub fn style(&self) -> Option<HeaderStyle>

The declared style, if any.

Source

pub fn with_style(self, style: HeaderStyle, explode: bool) -> Self

Sets the serialization style and explode flag.

A no-op on a content-described header, which has no style to set.

Naming HeaderStyle::Simple is not redundant even though it is the only style a header may take: the specification distinguishes a header that states it from one that leaves it out, and a description that stated it is emitted back the way it arrived.

Source

pub fn examples(&self) -> Option<&Examples>

The examples this header carries, if it carries any.

Source

pub fn example(&self) -> Option<&Value>

The inline example, when the value is shown with one.

Source

pub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>

The named examples, when the value is shown with those.

Source

pub fn with_example(self, value: impl Into<Value>) -> Self

Shows the value with one inline example.

Replaces any named examples: the two forms exclude each other, so there is no state that holds both.

Source

pub fn with_named_example( self, name: impl Into<String>, example: Example, ) -> Self

Adds a named example, replacing any inline one.

Source

pub fn with_named_example_ref( self, name: impl Into<String>, example: Ref, ) -> Self

Adds a named example held in Components::examples.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Sets the description.

Source

pub fn required(self, required: bool) -> Self

Marks the header mandatory.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

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

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

impl<'de> Deserialize<'de> for Header

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Header

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Header

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.