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: ExtensionsSpecification extensions.
Implementations§
Source§impl Header
impl Header
Sourcepub fn with_content(media_type: impl Into<String>, value: MediaType) -> Self
pub fn with_content(media_type: impl Into<String>, value: MediaType) -> Self
Creates a header described by one media type.
Sourcepub fn shape(&self) -> &HeaderShape
pub fn shape(&self) -> &HeaderShape
How this header’s value is described.
Sourcepub fn shape_mut(&mut self) -> &mut HeaderShape
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.
Sourcepub fn content(&self) -> Option<(&str, &MediaType)>
pub fn content(&self) -> Option<(&str, &MediaType)>
The media type and its description, when this header uses content.
Sourcepub fn style(&self) -> Option<HeaderStyle>
pub fn style(&self) -> Option<HeaderStyle>
The declared style, if any.
Sourcepub fn with_style(self, style: HeaderStyle, explode: bool) -> Self
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.
Sourcepub fn examples(&self) -> Option<&Examples>
pub fn examples(&self) -> Option<&Examples>
The examples this header carries, if it carries any.
Sourcepub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>
pub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>
The named examples, when the value is shown with those.
Sourcepub fn with_example(self, value: impl Into<Value>) -> Self
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.
Sourcepub fn with_named_example(
self,
name: impl Into<String>,
example: Example,
) -> Self
pub fn with_named_example( self, name: impl Into<String>, example: Example, ) -> Self
Adds a named example, replacing any inline one.
Sourcepub fn with_named_example_ref(
self,
name: impl Into<String>,
example: Ref,
) -> Self
pub fn with_named_example_ref( self, name: impl Into<String>, example: Ref, ) -> Self
Adds a named example held in
Components::examples.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Sets the description.