Trait UserAgentProvider
pub trait UserAgentProvider:
Send
+ Sync
+ 'static {
// Required method
fn select_user_agent_profile(
&self,
extensions: &Extensions,
) -> 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 theUserAgentin the context, or falls back to a random profile if configured withUserAgentSelectFallback::RandomOption<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,
extensions: &Extensions,
) -> Option<&UserAgentProfile>
fn select_user_agent_profile( &self, extensions: &Extensions, ) -> Option<&UserAgentProfile>
Selects a user agent profile based on the current context.