Struct dyer::component::affix::Affix [−][src]
pub struct Affix { /* fields omitted */ }
Expand description
generally, it provide extra infomation , meta data required by server,
including User-Agent
, Accept-Encoding
and so on.
Implementations
Create an instance of AffixBuilder
that used to build a Affix
Examples
let affix = affix::builder()
.header("accept", "*/*")
.body(())
.unwrap();
get shared reference to headers of Affix
Examples
let affix = Affix::builder()
.body(());
assert!(affix.headers().is_empty());
get mutable reference to headers of Affix
Examples
let affix = Affix::builder()
.body(());
affix.headers_mut().insert(Method::ACCEPT, "*/*".into());
assert!(!affix.headers().is_empty());
get shared reference to exts of Affix
Examples
let affix = Affix::builder()
.body(());
assert!(affix.exts().is_empty());
get mutable reference to exts of Affix
Examples
struct S {}
let affix = Affix::builder()
.body(());
let s = S {};
affix.exts_mut().insert(s);
assert_eq!(affix.exts().get::<S>(), Some(&s));
get mutable reference to rank of Affix
Examples
let affix = Affix::builder()
.body(());
affix.rank_mut() = 3;
assert_eq!(*affix.rank(), 3);
get mutable reference to body of Affix
Examples
let affix = Affix::builder()
.body(Vec::new());
affix.body_mut().extend(vec![1,2,3]);
assert_eq!(*affix.body().get::<Vec<i32>>, Some(&vec![1,2,3]));
get shared reference to body of Affix
Examples
let affix = Affix::builder()
.body(());
assert!(affix.body().is_empty());
Consume the affix and obtain the body
Examples
let affix = Affix::builder()
.body(Vec::new());
let body = affix.into_body()
assert_eq!(body, vec::new());
Convert the body of the Affix
with function
Examples
let affix = Affix::builder()
.body(vec![1,2,3]);
let new_affix = affix.map(|v| v + 1 );
assert_eq!(new_affix.body, vec![2,3,4]);
Create new affix
directly with body, inner data
Examples
let affix = affix::builder()
.get("https://example.com")
.body(vec![1,2,3]);
let ( mut inner, body, meta ) = affix.into_parts();
inner.version = Version::HTTP_3;
let new_affix = affix::from_parts(inner, body, meta);
split affix
into body, inner data
Examples
let affix = affix::builder()
.get("https://example.com")
.body(vec![1,2,3]);
let (_inner, _body, _meta ) = affix.into_parts();
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Affix
impl !UnwindSafe for Affix
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more