Struct relevancy::RelevancyStore
source · pub struct RelevancyStore { /* private fields */ }
Implementations§
source§impl RelevancyStore
impl RelevancyStore
Top-level API for the Relevancy component
sourcepub fn new(db_path: String) -> Self
pub fn new(db_path: String) -> Self
Construct a new RelevancyStore
This is non-blocking since databases and other resources are lazily opened.
sourcepub fn close(&self)
pub fn close(&self)
Close any open resources (for example databases)
Calling close
will interrupt any in-progress queries on other threads.
sourcepub fn ingest(
&self,
top_urls_by_frecency: Vec<String>
) -> ApiResult<InterestVector>
pub fn ingest( &self, top_urls_by_frecency: Vec<String> ) -> ApiResult<InterestVector>
Ingest top URLs to build the user’s interest vector.
Consumer should pass a list of the user’s top URLs by frecency to this method. It will then:
- Download the URL interest data from remote settings. Eventually this should be cached / stored in the database, but for now it would be fine to download fresh data each time.
- Match the user’s top URls against the interest data to build up their interest vector.
- Store the user’s interest vector in the database.
This method may execute for a long time and should only be called from a worker thread.
sourcepub fn calculate_metrics(&self) -> ApiResult<InterestMetrics>
pub fn calculate_metrics(&self) -> ApiResult<InterestMetrics>
Calculate metrics for the validation phase
This runs after Self::ingest. It takes the interest vector that ingest created and calculates a set of metrics that we can report to glean.
sourcepub fn user_interest_vector(&self) -> ApiResult<InterestVector>
pub fn user_interest_vector(&self) -> ApiResult<InterestVector>
Get the user’s interest vector directly.
This runs after Self::ingest. It returns the interest vector directly so that the
consumer can show it in an about:
page.
source§impl RelevancyStore
impl RelevancyStore
sourcepub fn ensure_interest_data_populated(&self) -> ApiResult<()>
pub fn ensure_interest_data_populated(&self) -> ApiResult<()>
Download the interest data from remote settings if needed
pub fn classify( &self, top_urls_by_frecency: Vec<String> ) -> Result<InterestVector>
Trait Implementations§
source§impl<UT> LiftRef<UT> for RelevancyStore
impl<UT> LiftRef<UT> for RelevancyStore
type LiftType = Arc<RelevancyStore>
source§impl<UT> LowerError<UT> for RelevancyStore
impl<UT> LowerError<UT> for RelevancyStore
source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
source§impl<UT> LowerReturn<UT> for RelevancyStore
impl<UT> LowerReturn<UT> for RelevancyStore
§type ReturnType = <Arc<RelevancyStore> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<RelevancyStore> as LowerReturn<UniFfiTag>>::ReturnType
source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
§fn handle_failed_lift(
error: LiftArgsError
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError ) -> Result<Self::ReturnType, RustCallError>
source§impl<UT> TypeId<UT> for RelevancyStore
impl<UT> TypeId<UT> for RelevancyStore
const TYPE_ID_META: MetadataBuffer = _
Auto Trait Implementations§
impl !Freeze for RelevancyStore
impl !RefUnwindSafe for RelevancyStore
impl Send for RelevancyStore
impl Sync for RelevancyStore
impl Unpin for RelevancyStore
impl !UnwindSafe for RelevancyStore
Blanket Implementations§
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<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Read more