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 the rank of Affix

Examples
let affix = Affix::builder()
    .body(());
assert_eq!(affix.rank(), 0);

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

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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