Struct relevancy::RelevancyStore

source ·
pub struct RelevancyStore { /* private fields */ }

Implementations§

source§

impl RelevancyStore

Top-level API for the Relevancy component

source

pub fn new(db_path: String) -> Self

Construct a new RelevancyStore

This is non-blocking since databases and other resources are lazily opened.

source

pub fn close(&self)

Close any open resources (for example databases)

Calling close will interrupt any in-progress queries on other threads.

source

pub fn interrupt(&self)

Interrupt any current database queries

source

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.

source

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.

source

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

source

pub fn ensure_interest_data_populated(&self) -> ApiResult<()>

Download the interest data from remote settings if needed

source

pub fn classify( &self, top_urls_by_frecency: Vec<String> ) -> Result<InterestVector>

Trait Implementations§

source§

impl<UT> LiftRef<UT> for RelevancyStore

source§

impl<UT> LowerError<UT> for RelevancyStore

source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
source§

impl<UT> LowerReturn<UT> for RelevancyStore

§

type ReturnType = <Arc<RelevancyStore> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
§

fn handle_failed_lift( error: LiftArgsError ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
source§

impl<UT> TypeId<UT> for RelevancyStore

source§

const TYPE_ID_META: MetadataBuffer = _

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.