Skip to main content

Profile

Struct Profile 

Source
pub struct Profile { /* private fields */ }
Available on crate feature user-agents only.
Expand description

A browser version and platform with navigation headers for a page opened directly.

The latest capture supplies header values; other major versions substitute the version into the user agent and Chromium client hints. This does not emulate TLS, HTTP/2, or the browser’s networking stack.

use uagent::{Browser, Platform, Profile};
let profile = Profile::new(Browser::Chrome, Platform::Windows)?;
assert_eq!(profile.version(), Browser::Chrome.latest());

Implementations§

Source§

impl Profile

Source

pub fn new(browser: Browser, platform: Platform) -> Result<Profile, Error>

Creates a profile of browser on platform at its latest bundled version.

§Errors

Returns an error if the browser/platform combination has no template.

Source

pub fn with_version(self, version: u32) -> Result<Profile, Error>

Overrides the browser’s major version.

Other major versions reuse the latest captured navigation headers; historical header changes are not modeled.

§Errors

Returns Error::InvalidVersion if version is zero.

Source

pub const fn with_latest_version(self) -> Profile

Restores the browser’s latest bundled major version after an override.

Source

pub fn with_language(self, language: &str) -> Result<Profile, Error>

Overrides the captured Accept-Language value.

Accepts a BCP 47 language tag or a comma-separated list of language tags and optional quality values, such as de-DE,de;q=0.9. * is also allowed.

§Errors

Returns Error::InvalidLanguage for invalid tags, quality values, or characters that cannot appear in the header.

Source

pub const fn browser(&self) -> Browser

Returns the browser.

Source

pub const fn version(&self) -> u32

Returns the major version.

Source

pub const fn platform(&self) -> Platform

Returns the platform.

Source

pub fn user_agent(&self) -> String

Returns the captured user agent with the requested version and platform.

Chromium reduces its version to the major; Safari retains the captured minor/patch suffix. Platform variants without captures use the draft’s fixed platform descriptions.

Source

pub fn headers(&self) -> Vec<Header>

Returns header names and values in capture order, excluding transport headers (Host, connection management, and Accept-Encoding).

Accept-Encoding belongs to the HTTP client, which knows its decoders. Header order is a convenience for clients that support it; an HTTP header map does not preserve it.

Trait Implementations§

Source§

impl Clone for Profile

Source§

fn clone(&self) -> Profile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Profile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Profile

Source§

impl PartialEq for Profile

Source§

fn eq(&self, other: &Profile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Profile

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

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

fn in_current_span(self) -> Instrumented<Self> ⓘ

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<W> WorkerExt for W

Source§

fn layer<C, M>(self, middleware: M) -> Layered<M, C>
where C: Send + 'static, Self: Worker<C>, M: Middleware<C>,

Wraps this worker in middleware, which runs before it, and before any middleware added earlier.