Skip to main content

JsonStorage

Struct JsonStorage 

Source
pub struct JsonStorage { /* private fields */ }
Expand description

JSON-backed corpus storage. Wraps a MemoryStorage with load/save against a file. On-disk format matches Ruby + Go byte-for-byte (modulo serde key-ordering inside maps, which neither runtime preserves through json marshal/unmarshal).

Implementations§

Source§

impl JsonStorage

Source

pub fn open(path: &str, max_values: usize) -> Result<Self>

Trait Implementations§

Source§

impl Storage for JsonStorage

Source§

fn max_values(&self) -> usize

Source§

fn increment_host(&mut self, host: &str)

Source§

fn increment_path_length(&mut self, length: usize)

Source§

fn increment_raw_shape(&mut self, shape: &str)

Source§

fn increment_fingerprint(&mut self, shape: &str)

Source§

fn observe_position(&mut self, pos: &Position, value: &str, t: SegmentType)

Source§

fn add_to_cluster( &mut self, key: &str, host: &str, scheme: &str, shape: &str, iri: &Identifier, )

Source§

fn host_counts(&self) -> HashMap<String, usize>

Source§

fn path_length_counts(&self) -> HashMap<usize, usize>

Source§

fn raw_shape_counts(&self) -> HashMap<String, usize>

Source§

fn fingerprint_counts(&self) -> HashMap<String, usize>

Source§

fn position_stats_for(&self, pos: &Position) -> Option<PositionStats>

Source§

fn each_position_stats(&self, f: &mut dyn FnMut(&Position, &PositionStats))

Source§

fn clusters(&self) -> Vec<Cluster>

Source§

fn cluster_for(&self, key: &str) -> Option<Cluster>

Source§

fn cluster_size(&self) -> usize

Source§

fn record_observation(&mut self, canonical: &str)

Source§

fn each_observed_iri(&self, f: &mut dyn FnMut(&str))

Source§

fn observed_iri_count(&self) -> usize

Source§

fn clear_materialized_views(&mut self)

Source§

fn record_activated_recognizer(&mut self, dump: Value)

Source§

fn each_activated_recognizer(&self, f: &mut dyn FnMut(&Value))

Source§

fn activated_recognizer_count(&self) -> usize

Source§

fn flush(&mut self) -> Result<()>

Source§

fn save_to(&mut self, path: &str) -> Result<()>

Source§

fn path(&self) -> Option<String>

Source§

fn for_each_host(&self, f: &mut dyn FnMut(&str, usize))

Visit each (host, count) without materializing a HashMap. Default falls back to a full materialization for backends that can’t stream.
Source§

fn for_each_raw_shape(&self, f: &mut dyn FnMut(&str, usize))

Source§

fn for_each_fingerprint(&self, f: &mut dyn FnMut(&str, usize))

Source§

fn batch_begin(&mut self) -> Result<()>

Wraps a closure in a single backend transaction. SQLite turns O(observations) fsyncs into one; Memory + JSON are no-ops.
Source§

fn batch_commit(&mut self) -> Result<()>

Source§

fn close(&mut self) -> Result<()>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

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>,

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.