#[non_exhaustive]pub struct StreamContext {
pub format: Cow<'static, str>,
pub direction: Direction,
pub side: Side,
pub status: Option<u16>,
pub content_length: Option<u64>,
pub content_type: Option<String>,
pub max_obj_len: Option<usize>,
pub buf_capacity: Option<usize>,
}Expand description
What a stream is about, for the span covering it.
Fields the caller cannot know are simply left None and are omitted from the span rather
than reported as a placeholder.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.format: Cow<'static, str>The format’s format_name.
Cow rather than &'static str because axum-streams’ long-standing public
StreamingFormat::format_name returns a borrowed &str, and that signature cannot
change without breaking the third-party implementations it was made public for.
Core’s own formats all return &'static str and so allocate nothing.
direction: DirectionRequest or response body.
side: SideClient or server.
status: Option<u16>Response status, where one is known.
content_length: Option<u64>Declared body length, where one is known.
content_type: Option<String>The negotiated content type, where one is known.
max_obj_len: Option<usize>The per-object limit in force, where one applies.
buf_capacity: Option<usize>The read-buffer size in force, where one applies.
Implementations§
Source§impl StreamContext
impl StreamContext
Sourcepub fn new(
format: impl Into<Cow<'static, str>>,
direction: Direction,
side: Side,
) -> Self
pub fn new( format: impl Into<Cow<'static, str>>, direction: Direction, side: Side, ) -> Self
A context for format, in the given direction and on the given side.
Sourcepub fn content_length(self, len: Option<u64>) -> Self
pub fn content_length(self, len: Option<u64>) -> Self
Record the declared body length.
Sourcepub fn content_type(self, ct: impl Into<String>) -> Self
pub fn content_type(self, ct: impl Into<String>) -> Self
Record the content type.
Sourcepub fn max_obj_len(self, len: usize) -> Self
pub fn max_obj_len(self, len: usize) -> Self
Record the per-object limit.
Sourcepub fn buf_capacity(self, cap: usize) -> Self
pub fn buf_capacity(self, cap: usize) -> Self
Record the read-buffer size.
Trait Implementations§
Source§impl Clone for StreamContext
impl Clone for StreamContext
Source§fn clone(&self) -> StreamContext
fn clone(&self) -> StreamContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more