pub struct Experience { /* private fields */ }Implementations§
Source§impl Experience
impl Experience
Source§impl Experience
impl Experience
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>>
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.
Sourcepub fn to_bytes_at(&self, seq: u64) -> Result<Vec<u8>>
pub fn to_bytes_at(&self, seq: u64) -> Result<Vec<u8>>
Self::to_bytes recording that the journal is folded in through seq.
Sourcepub fn save(&self, dir: &Path) -> Result<()>
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.
Sourcepub fn open(dir: &Path, cfg: ExperienceConfig) -> Result<Self>
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.
pub fn from_bytes(bytes: &[u8], cfg: ExperienceConfig) -> Result<Self>
Sourcepub fn from_bytes_at(bytes: &[u8], cfg: ExperienceConfig) -> Result<(Self, u64)>
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
impl Experience
pub fn new(cfg: ExperienceConfig) -> Self
pub fn config(&self) -> &ExperienceConfig
Sourcepub fn has_episode(&self, id: &str) -> bool
pub fn has_episode(&self, id: &str) -> bool
Whether the episode is stored.
Sourcepub fn episode_description(&self, id: &str) -> Option<(&str, &str)>
pub fn episode_description(&self, id: &str) -> Option<(&str, &str)>
The goal and outcome of an episode.
Sourcepub fn describe_episode(
&mut self,
episode: &str,
goal: &str,
outcome: &str,
) -> Result<()>
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.
Sourcepub fn ingest(&mut self, o: &Observation<'_>) -> Result<Ingested>
pub fn ingest(&mut self, o: &Observation<'_>) -> Result<Ingested>
Ingests one observation step. Retrying a step with identical content changes nothing.
Sourcepub fn extract_controls(&self, accessibility_tree: &str) -> Result<Vec<Control>>
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.
Sourcepub fn ingest_with_controls(
&mut self,
o: &Observation<'_>,
controls: Vec<Control>,
) -> Result<Ingested>
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.
pub fn stats(&self) -> ExperienceStats
Sourcepub fn search_regions(&self, query: &str, k: usize) -> Result<Vec<RegionHit>>
pub fn search_regions(&self, query: &str, k: usize) -> Result<Vec<RegionHit>>
Regions ranked by the lexical index, each with where it occurred.
Sourcepub fn region_hit(&self, rid: u32) -> Option<RegionHit>
pub fn region_hit(&self, rid: u32) -> Option<RegionHit>
One region by id, with where it occurred; its score is 0.
Sourcepub fn has_regions(&self) -> bool
pub fn has_regions(&self) -> bool
Whether any region is stored, that is, whether a search can return anything.
Sourcepub fn is_searchable(&self) -> bool
pub fn is_searchable(&self) -> bool
Whether anything of the experience core is searchable by recall.
Sourcepub fn template_id(&self, url: Option<&str>, title: &str) -> Option<u32>
pub fn template_id(&self, url: Option<&str>, title: &str) -> Option<u32>
The template of a page, if any observation of it is stored.
pub fn templates(&self) -> Vec<TemplateInfo>
Sourcepub fn line_observations(&self, template: u32, line: &str) -> u32
pub fn line_observations(&self, template: u32, line: &str) -> u32
How many observations of the template showed line.
Sourcepub fn effects(
&self,
template: u32,
action: Option<&str>,
top: usize,
) -> Vec<EffectView>
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.
Sourcepub fn quota_units(&self) -> u64
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.
Sourcepub fn has_step(&self, episode: &str, step: u32) -> bool
pub fn has_step(&self, episode: &str, step: u32) -> bool
Whether step of episode is already stored, so ingesting it again adds nothing.
Sourcepub fn check_snapshot_size(&self) -> Result<()>
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.
pub fn has_effects(&self) -> bool
Sourcepub fn search_effects(&self, query: &str, k: usize) -> Result<Vec<EffectHit>>
pub fn search_effects(&self, query: &str, k: usize) -> Result<Vec<EffectHit>>
Action effects ranked by the lexical index over their rendered rows.
Sourcepub fn effect_hit(&self, id: &str) -> Option<EffectHit>
pub fn effect_hit(&self, id: &str) -> Option<EffectHit>
One effect row by its index id, with score 0.
Sourcepub fn list_episodes(
&mut self,
goal_text: &str,
k: usize,
) -> Result<Vec<EpisodeHit>>
pub fn list_episodes( &mut self, goal_text: &str, k: usize, ) -> Result<Vec<EpisodeHit>>
Episodes whose goal, outcome or action path matches the text.
Sourcepub fn step_controls(&self, episode: &str, step: u32) -> Option<&[Control]>
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.
Sourcepub fn form_tables<S: AsRef<str>>(&self, states: &[(S, u32)]) -> Vec<String>
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.
Sourcepub fn episode_ids(&self) -> Vec<String>
pub fn episode_ids(&self) -> Vec<String>
Ids of every stored episode, sorted.
Sourcepub fn action_targets(&self, episode: &str, step: u32) -> Option<ActionTargets>
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.
Sourcepub fn occurrence(&self, r: &OccurrenceRef) -> Option<OccurrenceNode>
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.
pub fn episode(&self, id: &str) -> Option<EpisodeView>
Sourcepub fn purge_episode(&mut self, id: &str) -> Option<PurgeReport>
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§
Auto Trait Implementations§
impl !Freeze for Experience
impl RefUnwindSafe for Experience
impl Send for Experience
impl Sync for Experience
impl Unpin for Experience
impl UnsafeUnpin for Experience
impl UnwindSafe for Experience
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.