Trait UserAgentProvider
pub trait UserAgentProvider<State>:
Send
+ Sync
+ 'static {
// Required method
fn select_user_agent_profile(
&self,
ctx: &Context<State>,
) -> Option<&UserAgentProfile>;
}
Expand description
A trait for providing user agent profiles for emulation.
This trait is used to select a user agent profile based on the current context. It’s a core component of the user agent emulation system, allowing different strategies for selecting which user agent profile to use for a request.
Rama provides several built-in implementations:
- [
()
]: Always returnsNone
, effectively disabling user agent emulation UserAgentProfile
: Always returns the same profileUserAgentDatabase
: Selects a profile based on theUserAgent
in the context, or falls back to a random profile if configured withUserAgentSelectFallback::Random
Option<P>
: Delegates to the inner provider ifSome
, otherwise returnsNone
This trait is typically used by UserAgentEmulateService
to select an appropriate
user agent profile for HTTP request emulation.
Required Methods§
fn select_user_agent_profile(
&self,
ctx: &Context<State>,
) -> Option<&UserAgentProfile>
fn select_user_agent_profile( &self, ctx: &Context<State>, ) -> Option<&UserAgentProfile>
Selects a user agent profile based on the current context.