pub struct UserAgentEmulateLayer<P> { /* private fields */ }Expand description
A layer that emulates a user agent profile.
See UserAgentEmulateService for more details.
This layer is used to emulate a user agent profile for a request.
It makes use of a UserAgentProvider (P) to select a user agent profile.
Implementations§
Source§impl<P> UserAgentEmulateLayer<P>
impl<P> UserAgentEmulateLayer<P>
Sourcepub fn new(provider: P) -> Self
pub fn new(provider: P) -> Self
Create a new UserAgentEmulateLayer with the given provider.
Sourcepub fn with_is_optional(self, optional: bool) -> Self
pub fn with_is_optional(self, optional: bool) -> Self
When no user agent profile was found it will fail the request unless optional is true. In case of the latter the service will do nothing.
Sourcepub fn set_is_optional(&mut self, optional: bool) -> &mut Self
pub fn set_is_optional(&mut self, optional: bool) -> &mut Self
When no user agent profile was found it will fail the request unless optional is true. In case of the latter the service will do nothing.
Sourcepub fn with_try_auto_detect_user_agent(
self,
try_auto_detect_user_agent: bool,
) -> Self
pub fn with_try_auto_detect_user_agent( self, try_auto_detect_user_agent: bool, ) -> Self
If true, the layer will try to auto-detect the user agent from the request, but only in case that info is not yet found in the context.
Sourcepub fn set_try_auto_detect_user_agent(
&mut self,
try_auto_detect_user_agent: bool,
) -> &mut Self
pub fn set_try_auto_detect_user_agent( &mut self, try_auto_detect_user_agent: bool, ) -> &mut Self
If true, the layer will try to auto-detect the user agent from the request, but only in case that info is not yet found in the context.
Sourcepub fn maybe_with_input_header_order(self, name: Option<HeaderName>) -> Self
pub fn maybe_with_input_header_order(self, name: Option<HeaderName>) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn maybe_set_input_header_order(
&mut self,
name: Option<HeaderName>,
) -> &mut Self
pub fn maybe_set_input_header_order( &mut self, name: Option<HeaderName>, ) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn with_input_header_order(self, name: HeaderName) -> Self
pub fn with_input_header_order(self, name: HeaderName) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn set_input_header_order(&mut self, name: HeaderName) -> &mut Self
pub fn set_input_header_order(&mut self, name: HeaderName) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn without_input_header_order(self) -> Self
pub fn without_input_header_order(self) -> Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn unset_input_header_order(&mut self) -> &mut Self
pub fn unset_input_header_order(&mut self) -> &mut Self
Define a header that if present is to contain a CSV header name list, that allows you to define the desired header order for the (extra) headers found in the input (http) request.
Extra meaning any headers not considered a base header and already defined by the (selected) User Agent Profile.
This can be useful because your http client might not respect the header casing and/or order of the headers taken together. Using this metadata allows you to communicate this data through anyway. If however your http client does respect casing and order, or you don’t care about some of it, you might not need it.
Sourcepub fn maybe_with_select_fallback(
self,
fb: Option<UserAgentSelectFallback>,
) -> Self
pub fn maybe_with_select_fallback( self, fb: Option<UserAgentSelectFallback>, ) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn maybe_set_select_fallback(
&mut self,
fb: Option<UserAgentSelectFallback>,
) -> &mut Self
pub fn maybe_set_select_fallback( &mut self, fb: Option<UserAgentSelectFallback>, ) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn with_select_fallback(self, fb: UserAgentSelectFallback) -> Self
pub fn with_select_fallback(self, fb: UserAgentSelectFallback) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn set_select_fallback(&mut self, fb: UserAgentSelectFallback) -> &mut Self
pub fn set_select_fallback(&mut self, fb: UserAgentSelectFallback) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn without_select_fallback(self) -> Self
pub fn without_select_fallback(self) -> Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Sourcepub fn unset_select_fallback(&mut self) -> &mut Self
pub fn unset_select_fallback(&mut self) -> &mut Self
Choose what to do in case no profile could be selected using the regular pre-conditions as specified by the provider.
Trait Implementations§
Source§impl<P: Clone> Clone for UserAgentEmulateLayer<P>
impl<P: Clone> Clone for UserAgentEmulateLayer<P>
Source§fn clone(&self) -> UserAgentEmulateLayer<P>
fn clone(&self) -> UserAgentEmulateLayer<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P: Debug> Debug for UserAgentEmulateLayer<P>
impl<P: Debug> Debug for UserAgentEmulateLayer<P>
Source§impl<S, P: Clone> Layer<S> for UserAgentEmulateLayer<P>
impl<S, P: Clone> Layer<S> for UserAgentEmulateLayer<P>
Source§type Service = UserAgentEmulateService<S, P>
type Service = UserAgentEmulateService<S, P>
Source§fn layer(&self, inner: S) -> Self::Service
fn layer(&self, inner: S) -> Self::Service
Source§fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl<P> !Freeze for UserAgentEmulateLayer<P>
impl<P> RefUnwindSafe for UserAgentEmulateLayer<P>where
P: RefUnwindSafe,
impl<P> Send for UserAgentEmulateLayer<P>where
P: Send,
impl<P> Sync for UserAgentEmulateLayer<P>where
P: Sync,
impl<P> Unpin for UserAgentEmulateLayer<P>where
P: Unpin,
impl<P> UnsafeUnpin for UserAgentEmulateLayer<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for UserAgentEmulateLayer<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more