Struct UserAgentDatabase
pub struct UserAgentDatabase { /* private fields */ }std and ua only.Expand description
In-memory catalogue of captured user-agent profiles.
Profiles are drawn per request flow by UserAgentDatabase::select, weighted by
how often each was observed, and can be looked up by exact User-Agent header value.
Implementations§
§impl UserAgentDatabase
impl UserAgentDatabase
pub fn select( &self, request: &SelectionRequest, seed: ProfileSeed, key: DrawKey, ) -> Result<SelectedProfile, SelectionError>
§impl UserAgentDatabase
impl UserAgentDatabase
pub fn try_embedded() -> Result<UserAgentDatabase, Box<dyn Error + Send + Sync>>
Available on crate feature embed-profiles only.
pub fn try_embedded() -> Result<UserAgentDatabase, Box<dyn Error + Send + Sync>>
embed-profiles only.Load the profiles embedded with the rama-ua crate.
This function is only available if the embed-profiles feature is enabled.
pub fn try_from_json_slice(
bytes: &[u8],
) -> Result<UserAgentDatabase, Box<dyn Error + Send + Sync>>
pub fn try_from_json_slice( bytes: &[u8], ) -> Result<UserAgentDatabase, Box<dyn Error + Send + Sync>>
Load a user-agent database from a JSON array of
UserAgentProfileInput rows.
Complementary rows with the same User-Agent are merged and converted into captured profiles; missing HTTP/1, HTTP/2 or TLS components are never synthesized.
pub fn try_from_archive( bytes: &[u8], authorized: bool, current_day: u32, horizon: u32, limits: ProfileArchiveLimits, ) -> Result<UserAgentDatabase, Box<dyn Error + Send + Sync>>
pub fn candidates( &self, filter: ProfileCandidateFilter<'_>, ) -> Result<Box<[ProfileCandidate<'_>]>, ProfileDataError>
pub fn iter_ua_str(&self) -> impl Iterator<Item = &str>
pub fn iter_ua_str(&self) -> impl Iterator<Item = &str>
Iterate over the User-Agent header value strings in the database.
pub fn insert(&mut self, profile: UserAgentProfile)
pub fn insert(&mut self, profile: UserAgentProfile)
Insert a new UserAgentProfile into the database,
also indexing it by its User-Agent header value.
pub fn get_exact_header_str(
&self,
ua: &str,
) -> impl Iterator<Item = &UserAgentProfile>
pub fn get_exact_header_str( &self, ua: &str, ) -> impl Iterator<Item = &UserAgentProfile>
Every UserAgentProfile observed with exactly this User-Agent header value.
pub fn iter(&self) -> impl Iterator<Item = &UserAgentProfile>
pub fn iter(&self) -> impl Iterator<Item = &UserAgentProfile>
Iterate over all UserAgentProfiles in the database.
Trait Implementations§
§impl Debug for UserAgentDatabase
impl Debug for UserAgentDatabase
§impl Default for UserAgentDatabase
impl Default for UserAgentDatabase
§fn default() -> UserAgentDatabase
fn default() -> UserAgentDatabase
§impl FromIterator<UserAgentProfile> for UserAgentDatabase
impl FromIterator<UserAgentProfile> for UserAgentDatabase
§fn from_iter<T>(iter: T) -> UserAgentDatabasewhere
T: IntoIterator<Item = UserAgentProfile>,
fn from_iter<T>(iter: T) -> UserAgentDatabasewhere
T: IntoIterator<Item = UserAgentProfile>,
§impl ProfileSource for UserAgentDatabase
impl ProfileSource for UserAgentDatabase
§fn select_profile(
&self,
request: &SelectionRequest,
seed: ProfileSeed,
key: DrawKey,
) -> Result<SelectedProfile, SelectionError>
fn select_profile( &self, request: &SelectionRequest, seed: ProfileSeed, key: DrawKey, ) -> Result<SelectedProfile, SelectionError>
Auto Trait Implementations§
impl Freeze for UserAgentDatabase
impl RefUnwindSafe for UserAgentDatabase
impl Send for UserAgentDatabase
impl Sync for UserAgentDatabase
impl Unpin for UserAgentDatabase
impl UnsafeUnpin for UserAgentDatabase
impl UnwindSafe for UserAgentDatabase
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more