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 + Sync + Send>>
Available on crate feature embed-profiles only.
pub fn try_embedded() -> Result<UserAgentDatabase, Box<dyn Error + Sync + Send>>
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 + Sync + Send>>
pub fn try_from_json_slice( bytes: &[u8], ) -> Result<UserAgentDatabase, Box<dyn Error + Sync + Send>>
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 + Sync + Send>>
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 Forget for UserAgentDatabase
impl Freeze for UserAgentDatabasewhere
*const u8 is !null: Freeze,
PhantomData<UserAgentProfile>: Freeze,
PhantomData<Option<Arc<RequestShapeCache>>>: Freeze,
*const ArcInner<DatabaseEvidence> is !null: Freeze,
PhantomData<ArcInner<DatabaseEvidence>>: Freeze,
PhantomData<((Box<str>, Option<PlatformKind>, Option<DeviceKind>), BTreeMap<ProfileVersion, Vec<usize>>)>: Freeze,
PhantomData<(Box<str>, Vec<usize>)>: Freeze,
impl Move for UserAgentDatabase
impl RefUnwindSafe for UserAgentDatabasewhere
Atomic<usize>: RefUnwindSafe,
Atomic<*mut ()>: RefUnwindSafe,
OnceLock<DecodedRequests>: RefUnwindSafe,
OnceLock<[CookieLayoutEvidence; 2]>: RefUnwindSafe,
OnceLock<FlowVersions>: RefUnwindSafe,
OnceLock<ConnectionModes>: RefUnwindSafe,
OnceLock<OrdinaryEvidence>: RefUnwindSafe,
OnceLock<HashMap<Box<str>, FamilyIndex, RandomState>>: RefUnwindSafe,
impl Send for UserAgentDatabasewhere
RawVecInner: Send,
BoxRaw<str>: Send,
Arc<AnalyzedProfile>: Send,
Arc<UserAgentRuntimeProfile>: Send,
Arc<RequestShapeCache>: Send,
Arc<DatabaseEvidence>: Send,
RawTable<((Box<str>, Option<PlatformKind>, Option<DeviceKind>), BTreeMap<ProfileVersion, Vec<usize>>)>: Send,
RawTable<(Box<str>, Vec<usize>)>: Send,
impl Sync for UserAgentDatabasewhere
RawVecInner: Sync,
BoxRaw<str>: Sync,
Arc<AnalyzedProfile>: Sync,
Arc<UserAgentRuntimeProfile>: Sync,
Arc<RequestShapeCache>: Sync,
Arc<DatabaseEvidence>: Sync,
RawTable<((Box<str>, Option<PlatformKind>, Option<DeviceKind>), BTreeMap<ProfileVersion, Vec<usize>>)>: Sync,
RawTable<(Box<str>, Vec<usize>)>: Sync,
impl Unpin for UserAgentDatabase
impl UnsafeUnpin for UserAgentDatabasewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<UserAgentProfile>: UnsafeUnpin,
PhantomData<Option<Arc<RequestShapeCache>>>: UnsafeUnpin,
*const ArcInner<DatabaseEvidence> is !null: UnsafeUnpin,
PhantomData<ArcInner<DatabaseEvidence>>: UnsafeUnpin,
PhantomData<((Box<str>, Option<PlatformKind>, Option<DeviceKind>), BTreeMap<ProfileVersion, Vec<usize>>)>: UnsafeUnpin,
PhantomData<(Box<str>, Vec<usize>)>: UnsafeUnpin,
impl UnwindSafe for UserAgentDatabasewhere
RawVecInner: UnwindSafe,
BoxRaw<str>: UnwindSafe,
Arc<AnalyzedProfile>: UnwindSafe,
Arc<UserAgentRuntimeProfile>: UnwindSafe,
Arc<RequestShapeCache>: UnwindSafe,
Arc<DatabaseEvidence>: UnwindSafe,
HashMap<(Box<str>, Option<PlatformKind>, Option<DeviceKind>), BTreeMap<ProfileVersion, Vec<usize>>, RandomState>: UnwindSafe,
HashMap<Box<str>, Vec<usize>, RandomState>: UnwindSafe,
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