Skip to main content

Experience

Struct Experience 

Source
pub struct Experience { /* private fields */ }

Implementations§

Source§

impl Experience

Source

pub fn state_diff( &self, episode: &str, from: u32, to: u32, ) -> Option<Vec<Change>>

What changed between two steps of an episode, by address. None when either step is not stored. Identical content short-circuits through the interned root.

Source§

impl Experience

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

The versioned, checksummed snapshot: a 20-byte header (magic, version, payload length, CRC32 of the payload) and a CBOR payload.

Source

pub fn to_bytes_at(&self, seq: u64) -> Result<Vec<u8>>

Self::to_bytes recording that the journal is folded in through seq.

Source

pub fn save(&self, dir: &Path) -> Result<()>

Writes the snapshot into dir atomically: a crash leaves the previous snapshot or the new one, never a mix.

Source

pub fn open(dir: &Path, cfg: ExperienceConfig) -> Result<Self>

Opens the snapshot in dir, or an empty store when there is none. A damaged snapshot is an error, never an empty store.

Source

pub fn from_bytes(bytes: &[u8], cfg: ExperienceConfig) -> Result<Self>

Source

pub fn from_bytes_at(bytes: &[u8], cfg: ExperienceConfig) -> Result<(Self, u64)>

Self::from_bytes with the journal sequence the snapshot covers (0 for version 1).

Source§

impl Experience

Source

pub fn new(cfg: ExperienceConfig) -> Self

Source

pub fn config(&self) -> &ExperienceConfig

Source

pub fn has_episode(&self, id: &str) -> bool

Whether the episode is stored.

Source

pub fn episode_description(&self, id: &str) -> Option<(&str, &str)>

The goal and outcome of an episode.

Source

pub fn describe_episode( &mut self, episode: &str, goal: &str, outcome: &str, ) -> Result<()>

Sets the goal and outcome of an episode, creating it if needed.

Source

pub fn ingest(&mut self, o: &Observation<'_>) -> Result<Ingested>

Ingests one observation step. Retrying a step with identical content changes nothing.

Source

pub fn extract_controls(&self, accessibility_tree: &str) -> Result<Vec<Control>>

The form controls of an accessibility-tree text (form::extract_controls), bounded by this store’s limits; none when ExperienceConfig::form_state is off. The text is refused over max_page_bytes either way.

Source

pub fn ingest_with_controls( &mut self, o: &Observation<'_>, controls: Vec<Control>, ) -> Result<Ingested>

Self::ingest storing controls with the step. The controls are part of the step’s content: the same step again with other controls is a conflict.

Source

pub fn stats(&self) -> ExperienceStats

Source

pub fn search_regions(&self, query: &str, k: usize) -> Result<Vec<RegionHit>>

Regions ranked by the lexical index, each with where it occurred.

Source

pub fn region_hit(&self, rid: u32) -> Option<RegionHit>

One region by id, with where it occurred; its score is 0.

Source

pub fn has_regions(&self) -> bool

Whether any region is stored, that is, whether a search can return anything.

Source

pub fn is_searchable(&self) -> bool

Whether anything of the experience core is searchable by recall.

Source

pub fn template_id(&self, url: Option<&str>, title: &str) -> Option<u32>

The template of a page, if any observation of it is stored.

Source

pub fn templates(&self) -> Vec<TemplateInfo>

Source

pub fn line_observations(&self, template: u32, line: &str) -> u32

How many observations of the template showed line.

Source

pub fn effects( &self, template: u32, action: Option<&str>, top: usize, ) -> Vec<EffectView>

What actions on template change; one action when action is given. Lists are ordered by count and then text, each cut to top.

Source

pub fn quota_units(&self) -> u64

What counts against a tenant quota: one unit per episode, step, region and effect row, and one per started 4 KiB of form-control text of a step. A step counts because regions are keyed by structure, so steps that differ only in their props add no region yet each stores them.

Source

pub fn has_step(&self, episode: &str, step: u32) -> bool

Whether step of episode is already stored, so ingesting it again adds nothing.

Source

pub fn check_snapshot_size(&self) -> Result<()>

Fails when the snapshot of the current state would exceed the snapshot limit. Cheap while the estimate is well under the limit; near it, measures the real size.

Source

pub fn has_effects(&self) -> bool

Source

pub fn search_effects(&self, query: &str, k: usize) -> Result<Vec<EffectHit>>

Action effects ranked by the lexical index over their rendered rows.

Source

pub fn effect_hit(&self, id: &str) -> Option<EffectHit>

One effect row by its index id, with score 0.

Source

pub fn list_episodes( &mut self, goal_text: &str, k: usize, ) -> Result<Vec<EpisodeHit>>

Episodes whose goal, outcome or action path matches the text.

Source

pub fn step_controls(&self, episode: &str, step: u32) -> Option<&[Control]>

The form controls stored with a step; None when the step is not stored.

Source

pub fn form_tables<S: AsRef<str>>(&self, states: &[(S, u32)]) -> Vec<String>

The form tables of states in order (form::render_form_tables): each state’s controls, without those already shown for an earlier state of the list. A state that is not stored or has no controls gives an empty string.

Source

pub fn episode_ids(&self) -> Vec<String>

Ids of every stored episode, sorted.

Source

pub fn action_targets(&self, episode: &str, step: u32) -> Option<ActionTargets>

The action stored with step of episode, its predecessor and the occurrences it targeted. A reference with an empty path is the observation’s root.

Source

pub fn occurrence(&self, r: &OccurrenceRef) -> Option<OccurrenceNode>

The node an occurrence reference addresses, or None when the episode was purged or the path no longer addresses a node.

Source

pub fn episode(&self, id: &str) -> Option<EpisodeView>

Source

pub fn purge_episode(&mut self, id: &str) -> Option<PurgeReport>

Removes an episode and everything only it held; shared structure stays. Returns None for an unknown episode.

Trait Implementations§

Source§

impl Default for Experience

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
§

impl<T> WithSubscriber for T

§

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
§

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

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