Struct stam::AnnotationStore

source ·
pub struct AnnotationStore { /* private fields */ }
Expand description

An Annotation Store is a collection of annotations, resources and annotation data sets. It can be seen as the root of the graph model and the glue that holds everything together. It is the entry point for any stam model.

§Example

In the following example we instantiate an AnnotationStore with a text resource from scratch, and we add an annotation on the word “world”, indicating that it has “part-of-speech” tag “noun”.

let store = AnnotationStore::default()
    .with_id("example")
    .add(TextResource::from_string(
        "myresource",
        "Hello world",
        Config::default(),
    ))?
    .add(AnnotationDataSet::new(Config::default()).with_id("mydataset"))?
    .with_annotation(
        AnnotationBuilder::new()
            .with_id("A1")
            .with_target(SelectorBuilder::textselector(
                "myresource",
                Offset::simple(6, 11),
            ))
            .with_data_with_id("mydataset", "part-of-speech", "noun", "D1"),
    )?;

This can also be done a bit more verbosely as follows (but the end result is identical as above), here we explicitly build the AnnotationDataSet first and then add the annotation:

let store = AnnotationStore::new(Config::default())
    .with_id("example")
    .add(
        TextResourceBuilder::new()
            .with_id("myresource")
            .with_text("Hello world")
            .build()?,
    )?
    .add(
        AnnotationDataSet::new(Config::default())
            .with_id("mydataset")
            .add(DataKey::new("part-of-speech"))?
            .with_data_with_id("part-of-speech", "noun", "D1")?,
    )?
    .with_annotation(
        AnnotationBuilder::new()
            .with_id("A1")
            .with_target(SelectorBuilder::textselector(
                "myresource",
                Offset::simple(6, 11),
            ))
            .with_existing_data("mydataset", "D1"),
    )?;

In this example we used the builder pattern with AnnotationStore::with_annotation() and an AnnotationBuilder. We can also add annotations on-the-fly later using the AnnotationStore::annotate() method (see the example there).

Implementations§

source§

impl AnnotationStore

source

pub fn with_annotation( self, builder: AnnotationBuilder<'_> ) -> Result<Self, StamError>

Builds and adds an annotation

source

pub fn with_annotations( self, builders: Vec<AnnotationBuilder<'_>> ) -> Result<Self, StamError>

Builds and adds multiple annotations

source

pub fn insert_data( &mut self, dataitem: AnnotationDataBuilder<'_> ) -> Result<(AnnotationDataSetHandle, AnnotationDataHandle), StamError>

Builds and inserts an AnnotationData item

source

pub fn annotate( &mut self, builder: AnnotationBuilder<'_> ) -> Result<AnnotationHandle, StamError>

Builds and inserts an annotation. If you’re instantiating an annotation store from scratch a builder pattern, then you can use Self::with_annotation() instead.

§Example
//instantiate a store
let mut store = AnnotationStore::new(Config::default())
    .with_id("example")
    .add(
        TextResourceBuilder::new()
            .with_id("myresource")
            .with_text("Hello world")
            .build()?,
    )?
    .add(
        AnnotationDataSet::new(Config::default())
            .with_id("mydataset"),
    )?;

//do some other stuff in the middle (otherwise you could have just as well used with_annotation())

//and then annotate:
store.annotate(
    AnnotationBuilder::new()
        .with_id("A1")
        .with_target(SelectorBuilder::textselector(
            "myresource",
            Offset::simple(6, 11),
        ))
        .with_data_with_id("mydataset", "part-of-speech", "noun", "D1"),
    )?;
source

pub fn annotate_from_iter<'a, I>( &mut self, builders: I ) -> Result<Vec<AnnotationHandle>, StamError>
where I: IntoIterator<Item = AnnotationBuilder<'a>>,

Builds and inserts using multiple annotation builders. Returns the handles in a vector.

source§

impl AnnotationStore

source

pub fn new(config: Config) -> Self

Creates a new empty annotation store with a default configuraton, add the AnnotationStore::with_config() to provide a custom one See the top-level documentation for AnnotationStore for a complete example on instantiating a store from scratch.

source

pub fn from_file(filename: &str, config: Config) -> Result<Self, StamError>

Loads an AnnotationStore from a file (STAM JSON or another supported format) The file must contain a single object which has “@type”: “AnnotationStore”

source

pub fn from_str(string: &str, config: Config) -> Result<Self, StamError>

Loads an AnnotationStore from a STAM JSON string The string must contain a single object which has “@type”: “AnnotationStore”

source

pub fn with_file(self, filename: &str) -> Result<Self, StamError>

Merge another annotation store STAM JSON file into this one Note: The ID and filename of the store will not be overwritten if already set, reserialising the store will produce a single new store.

source

pub fn annotations_filename(&self) -> Option<&Path>

Returns the filename associated with this annotation store for storage of annotations Only used for STAM CSV, not for STAM JSON.

source

pub fn annotate_from_file( &mut self, filename: &str ) -> Result<&mut Self, StamError>

Load a JSON file containing an array of annotations in STAM JSON TODO: this is currently not efficient as it holds all annotation builders in memory first

source

pub fn to_file(&mut self, filename: &str) -> Result<(), StamError>

Write the annotation store and all files below it to file (STAM JSON or other supported formats likes STAM CSV) The filetype is determined by the extension.

source

pub fn save(&self) -> Result<(), StamError>

Shortcut to write an AnnotationStore to file, writes to the same file and in the same format as was loaded. Returns an error if no filename was associated yet. Use AnnotationStore::to_file() instead if you want to write elsewhere.

Note: If multiple stores were loaded and merged, this will write all merged results in place of the first loaded store!

source

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

Returns the ID of the annotation store (if any)

source

pub fn with_id(self, id: impl Into<String>) -> Self

Sets the ID of the annotation store in a builder pattern

source

pub fn add_resource_from_file( &mut self, filename: &str ) -> Result<TextResourceHandle, StamError>

Shortcut method to load a resource from file and add it to the store. Returns a handle, wrap it in a call to self.resource() to get the resource itself.

source

pub fn resolve_annotation_id( &self, id: &str ) -> Result<AnnotationHandle, StamError>

Get an annotation handle from an ID. Shortcut wraps arround get_handle()

source

pub fn resolve_dataset_id( &self, id: &str ) -> Result<AnnotationDataSetHandle, StamError>

Get an annotation dataset handle from an ID. Shortcut wraps arround get_handle()

source

pub fn resolve_resource_id( &self, id: &str ) -> Result<TextResourceHandle, StamError>

Get an annotation dataset handle from an ID. Shortcut wraps arround get_handle()

source

pub fn annotations_len(&self) -> usize

Returns the number of annotations in the store (deletions are not substracted)

source

pub fn resources_len(&self) -> usize

Returns the number of resources in the store (deletions are not substracted)

source

pub fn datasets_len(&self) -> usize

Returns the number of datasets in the store (deletions are not substracted)

source

pub fn selector( &mut self, item: SelectorBuilder<'_> ) -> Result<Selector, StamError>

Builds a Selector based on its SelectorBuilder, this will produce an error if the selected resource does not exist. This is a low-level method that you shouldn’t need to call yourself.

source

pub fn index_len( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)

Returns length for each of the reverse indices

  • dataset_data_annotation_map
  • textrelationmap
  • resource_annotation_metamap
  • dataset_annotation_metamap
  • annotation_annotation_map
  • resource id map
  • dataset id map
  • annotation id map
  • key_annotation_map (not used yet)
  • key_annotation_metamap
  • data_annotation_metamap
source

pub fn index_totalcount( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize)

Returns total counts for each of the reverse indices

  • dataset_data_annotation_map
  • textrelationmap
  • resource_annotation_map
  • dataset_annotation_map
  • annotation_annotation_map
source

pub fn index_meminfo( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)

Returns estimated lower-bound for memory consumption for each of the reverse indices

  • dataset_data_annotation_map
  • textrelationmap
  • resource_annotation_map
  • dataset_annotation_map
  • annotation_annotation_map
  • resource id map
  • dataset id map
  • annotation id map
  • key_annotation_map (not used yet)
  • key_annotation_metamap
  • data_annotation_metamap
source

pub fn annotations_meminfo(&self) -> usize

source

pub fn index_partialcount(&self) -> (usize, usize)

Returns partcial count for each of the triple reverse indices, does not count the deepest layer

  • dataset_data_annotation_map
  • textrelationmap
source

pub fn shrink_to_fit(&mut self, recursive: bool)

Re-allocates data structures to minimize memory consumption

source

pub fn reindex(self) -> Self

This reindexes all elements, effectively performing garbage collection and freeing any deleted items from memory permanently. You can only run this on a fully owned AnnotationStore. Many data structures will be reallocated from scratch so this is a fairly costly operation (and not everywhere as efficient as it could be). Fortunately, there is often little reason to call this method, serializing (e.g. to STAM JSON) and deserializing the data is usually preferred.

WARNING: This operation may invalidate any/all outstanding handles! Ensure you reobtain any handles anew after this operation.

Although Rust’s borrowing rules ensure there can be no external references alive during reindexing, this does not apply to the various handles that this library publishes.

source

pub fn strip_annotation_ids(&mut self)

Strip public identifiers from annotations. This will not affect any internal references but will render any references from external sources impossible.

source

pub fn strip_data_ids(&mut self)

Strip public identifiers from annotation data. This will not affect any internal references but will render any references from external sources impossible.

source§

impl AnnotationStore

source

pub fn resource( &self, request: impl Request<TextResource> ) -> Option<ResultItem<'_, TextResource>>

Requests a specific TextResource from the store to be returned by reference. The request parameter encapsulates some kind of identifier, it can be a &str, String or crate::TextResourceHandle.

The item is returned as a fat pointer ResultItem<TextResource>) in an Option. Returns None if it does not exist.

source

pub fn dataset( &self, request: impl Request<AnnotationDataSet> ) -> Option<ResultItem<'_, AnnotationDataSet>>

Requests a specific AnnotationDataSet from the store to be returned by reference. The request parameter encapsulates some kind of identifier, it can be a &str, String or AnnotationDataSetHandle.

source

pub fn key( &self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey> ) -> Option<ResultItem<'_, DataKey>>

Requests a specific DataKey (pertaining to an AnnotationDataSet) to be returned by reference.

source

pub fn annotationdata( &self, set: impl Request<AnnotationDataSet>, data: impl Request<AnnotationData> ) -> Option<ResultItem<'_, AnnotationData>>

Requests a specific AnnotationData (pertaining to an AnnotationDataSet) to be returned by reference.

source

pub fn textselection( &self, resource: impl Request<TextResource>, handle: TextSelectionHandle ) -> Option<ResultTextSelection<'_>>

Requests a specific TextSelection by handle (pertaining to an AnnotationDataSet) to be returned by reference.

source

pub fn annotation( &self, request: impl Request<Annotation> ) -> Option<ResultItem<'_, Annotation>>

Requests a specific Annotation from the store to be returned by reference. The request parameter encapsulates some kind of identifier, it can be a &str,String or AnnotationHandle.

The item is returned as a fat pointer ResultItem<Annotation>), which exposes the high-level API, in an Option. Returns None if it does not exist.

source

pub fn resources<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'_, TextResource>>>

Returns an iterator over all text resources (TextResource instances) in the store. Items are returned as a fat pointer ResultItem<TextResource>), which exposes the high-level API.

source

pub fn datasets<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'_, AnnotationDataSet>>>

Returns an iterator over all AnnotationDataSet instances in the store. Items are returned as a fat pointer ResultItem<AnnotationDataSet>), which exposes the high-level API.

source

pub fn annotations<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'a, Annotation>>>

Returns an iterator over all annotations (Annotation instances) in the store. The resulting iterator yields items as a fat pointer ResultItem<Annotation>), which exposes the high-level API.

source

pub fn find_data<'store, 'q>( &'store self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey>, value: DataOperator<'q> ) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>
where 'q: 'store,

Finds AnnotationData using data search criteria. This returns an iterator over all matches.

If you are not interested in returning the results but merely testing the presence of particular data, then use Self::test_data() instead..

You can pass a boolean (true/false, doesn’t matter) or empty string literal for set or key to represent any set/key. To search for any value, value must be explicitly set to DataOperator::Any to return all values.

Value is a DataOperator that can apply a data test to the value. Use DataOperator::Equals to search for an exact value. As a shortcut, you can pass "value".into() to automatically convert various data types into DataOperator::Equals.

Example call to retrieve all data indiscriminately: annotation.find_data(false,false, DataOperator::Any) .. or just use the alias function data().

Note: If you pass a key you must also pass set, otherwise the key will be ignored!! You can not search for keys if you don’t know their set!

§Example
//in this store we have a single annotation, and single annotation data with key 'part-of-speech' and value 'noun':
for annotationdata in store.find_data("mydataset", "part-of-speech", DataOperator::Equals("noun")) {
    assert_eq!(annotationdata.id(), Some("D1"));
    assert_eq!(annotationdata.value(), "noun");
}
source

pub fn data<'store>( &'store self ) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>

Returns an iterator over all data in all sets. If possible, use a more constrained method (on AnnotationDataSet or a DataKey), it will have better performance.

source

pub fn keys<'store>( &'store self ) -> <BTreeSet<ResultItem<'store, DataKey>> as IntoIterator>::IntoIter

Returns an iterator over all keys in all sets. If possible, use a more constrained method (on AnnotationDataSet), it will have better performance.

source

pub fn test_data<'store, 'a>( &'store self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey>, value: DataOperator<'a> ) -> bool
where 'a: 'store,

Tests if certain annotation data exists, returns a boolean. If you want to actually retrieve the data, use find_data() instead.

You can pass a boolean (true/false, doesn’t matter) or empty string literal for set or key to represent any set/key. To search for any value, value must be explicitly set to DataOperator::Any to return all values.

Note: This gives no guarantee that data, although it exists, is actually used by annotations.

source

pub fn resources_by_metadata<'store, 'a>( &'store self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey>, value: DataOperator<'a> ) -> impl Iterator<Item = (ResultItem<'store, TextResource>, ResultItem<'store, AnnotationData>)>
where 'a: 'store,

Searches for resources by metadata. Returns an iterator returning both the annotation, as well the annotation data

This may return the same resource multiple times if different matching data references it!

If you already have a ResultItem<AnnotationData> instance, just use ResultItem<AnnotationData>.resources_as_metadata() instead, it’ll be much more efficient.

See Self::find_data() for further parameter explanation.

source

pub fn datasets_by_metadata<'store, 'a>( &'store self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey>, value: DataOperator<'a> ) -> impl Iterator<Item = (ResultItem<'store, AnnotationDataSet>, ResultItem<'store, AnnotationData>)>
where 'a: 'store,

Searches for datasets by metadata. Returns an iterator returning both the annotation, as well the annotation data

This may return the same resource multiple times if different matching data references it!

If you already have a ResultItem<AnnotationData> instance, just use ResultItem<AnnotationData>.resources_as_metadata() instead, it’ll be much more efficient.

See Self::find_data() for further parameter explanation.

source§

impl<'store> AnnotationStore

source

pub fn query(&'store self, query: Query<'store>) -> QueryIter<'store>

Initializes a Query and returns an iterator (QueryIter) to loop over the results. Note that no actual querying is done yet until you use the iterator, the Query is lazy-evaluated.

§Examples
let query: Query = "SELECT ANNOTATION ?a WHERE DATA myset type = phrase;".try_into()?;
for results in store.query(query) {
    for result in results.iter() {
       if let QueryResultItem::Annotation(annotation) = result {
          unimplemented!("do something with the result...");
        }
    }
}

or by name:

let query: Query = "SELECT ANNOTATION ?a WHERE DATA myset type = phrase;".try_into()?;
let iter = store.query(query);
let names = iter.names();
for results in iter {
    if let Ok(result) = results.get_by_name(&names, "a") {
       if let QueryResultItem::Annotation(annotation) = result {
          unimplemented!("do something with the result...");
        }
    }
}
source§

impl AnnotationStore

source

pub fn find_text_regex<'store, 'r>( &'store self, expressions: &'r [Regex], precompiledset: &'r Option<RegexSet>, allow_overlap: bool ) -> impl Iterator<Item = FindRegexMatch<'store, 'r>>

Searches for text in all resources using one or more regular expressions, returns an iterator over TextSelections along with the matching expression, this See FindText::find_text_regex(). Note that this method, unlike its counterpart FindText::find_text_regex(), silently ignores any deeper errors that might occur.

source

pub fn find_text<'store, 'fragment>( &'store self, fragment: &'fragment str ) -> FindTextIter<'store, 'fragment>

source

pub fn find_text_nocase<'store>( &'store self, fragment: &str ) -> FindNoCaseTextIter<'store>

source§

impl AnnotationStore

source

pub fn to_csv_files(&self, filename: &str) -> Result<(), StamError>

Saves all files as CSV. It is better to use AnnotationStore::save() instead, setting [AnnotationStore::set_dataformat(DataFormat::Csv)] before invocation.

Trait Implementations§

source§

impl AssociatedFile for AnnotationStore

source§

fn filename(&self) -> Option<&str>

Returns the filename associated with this annotation store

source§

fn with_filename(self, filename: &str) -> Self

source§

fn set_filename(&mut self, filename: &str) -> &mut Self

source§

fn filename_without_extension(&self) -> Option<&str>

Returns the filename without (known!) extension. The extension must be a known extension used by STAM for this to work.
source§

fn filename_without_workdir(&self) -> Option<&str>

Serializes the filename ready for use with STAM JSON’s @include or STAM CSV. It basically only strips the workdir component, if any.
source§

impl Configurable for AnnotationStore

source§

fn config(&self) -> &Config

Return the associated configuration

source§

fn set_config(&mut self, config: Config) -> &mut Self

Sets the configuration, this will also overwrite all underlying configurations for annotation data sets and resources!

source§

fn config_mut(&mut self) -> &mut Config

source§

fn with_config(self, config: Config) -> Self

Builder pattern to associate a configuration
source§

impl Debug for AnnotationStore

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'bytes, Ctx> Decode<'bytes, Ctx> for AnnotationStore

source§

fn decode( __d777: &mut Decoder<'bytes>, __ctx777: &mut Ctx ) -> Result<AnnotationStore, Error>

Decode a value using the given Decoder. Read more
source§

fn nil() -> Option<Self>

If possible, return a nil value of Self. Read more
source§

impl Default for AnnotationStore

source§

fn default() -> Self

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

impl<Ctx> Encode<Ctx> for AnnotationStore

source§

fn encode<__W777>( &self, __e777: &mut Encoder<__W777>, __ctx777: &mut Ctx ) -> Result<(), Error<__W777::Error>>
where __W777: Write,

Encode a value of this type using the given Encoder. Read more
source§

fn is_nil(&self) -> bool

Is this value of Self a nil value? Read more
source§

impl FromCsv for AnnotationStore

source§

fn from_csv_reader( reader: Box<dyn BufRead>, filename: Option<&str>, config: Config ) -> Result<Self, StamError>

source§

fn from_csv_file(filename: &str, config: Config) -> Result<Self, StamError>

source§

impl FromJson for AnnotationStore

source§

fn from_json_file(filename: &str, config: Config) -> Result<Self, StamError>

Loads an AnnotationStore from a STAM JSON file The file must contain a single object which has “@type”: “AnnotationStore”

source§

fn from_json_str(string: &str, config: Config) -> Result<Self, StamError>

Loads an AnnotationStore from a STAM JSON string The string must contain a single object which has “@type”: “AnnotationStore”

source§

fn merge_json_file(&mut self, filename: &str) -> Result<(), StamError>

Merges an AnnotationStore from a STAM JSON file into the current one The file must contain a single object which has “@type”: “AnnotationStore”

source§

fn merge_json_str(&mut self, string: &str) -> Result<(), StamError>

Merges an AnnotationStore from a STAM JSON string into the current one The string must contain a single object which has “@type”: “AnnotationStore”

source§

impl Serialize for AnnotationStore

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StoreFor<Annotation> for AnnotationStore

source§

fn store(&self) -> &Store<Annotation>

Get a reference to the entire store for the associated type This is a low-level API method.
source§

fn store_mut(&mut self) -> &mut Store<Annotation>

Get a mutable reference to the entire store for the associated type This is a low-level API method.
source§

fn idmap(&self) -> Option<&IdMap<AnnotationHandle>>

Get a reference to the id map for the associated type, mapping global ids to internal ids This is a low-level API method.
source§

fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationHandle>>

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids This is a low-level API method.
source§

fn store_typeinfo() -> &'static str

source§

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.
source§

fn add(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern
source§

fn has(&self, item: impl Request<T>) -> bool

Returns true if the store has the item
source§

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity. Read more
source§

fn get(&self, item: impl Request<T>) -> Result<&T, StamError>

Get a reference to an item from the store This is a low-level API method, you usually want to use dedicated high-level methods like AnnotationStore::annotation() instead.
source§

fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID This is a low-level API method
source§

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed
source§

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle. Also works for temporary IDs if enabled. This is a low-level API method. You usually don’t want to call this directly.
source§

fn iter(&self) -> StoreIter<'_, T>
where T: Storable<StoreType = Self>,

Iterate over all items in the store This is a low-level API method, use dedicated high-level iterators like annotations(), resources() instead.
source§

fn iter_mut(&mut self) -> StoreIterMut<'_, T>

Iterate over the store, mutably This is a low-level API method.
source§

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store This is a low-level API method.
source§

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item This is a low-level API method.
source§

impl StoreFor<AnnotationDataSet> for AnnotationStore

source§

fn store(&self) -> &Store<AnnotationDataSet>

Get a reference to the entire store for the associated type This is a low-level API method.
source§

fn store_mut(&mut self) -> &mut Store<AnnotationDataSet>

Get a mutable reference to the entire store for the associated type This is a low-level API method.
source§

fn idmap(&self) -> Option<&IdMap<AnnotationDataSetHandle>>

Get a reference to the id map for the associated type, mapping global ids to internal ids This is a low-level API method.
source§

fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataSetHandle>>

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids This is a low-level API method.
source§

fn store_typeinfo() -> &'static str

source§

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.
source§

fn add(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern
source§

fn has(&self, item: impl Request<T>) -> bool

Returns true if the store has the item
source§

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity. Read more
source§

fn get(&self, item: impl Request<T>) -> Result<&T, StamError>

Get a reference to an item from the store This is a low-level API method, you usually want to use dedicated high-level methods like AnnotationStore::annotation() instead.
source§

fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID This is a low-level API method
source§

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed
source§

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle. Also works for temporary IDs if enabled. This is a low-level API method. You usually don’t want to call this directly.
source§

fn iter(&self) -> StoreIter<'_, T>
where T: Storable<StoreType = Self>,

Iterate over all items in the store This is a low-level API method, use dedicated high-level iterators like annotations(), resources() instead.
source§

fn iter_mut(&mut self) -> StoreIterMut<'_, T>

Iterate over the store, mutably This is a low-level API method.
source§

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store This is a low-level API method.
source§

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item This is a low-level API method.
source§

impl StoreFor<TextResource> for AnnotationStore

source§

fn store(&self) -> &Store<TextResource>

Get a reference to the entire store for the associated type

source§

fn store_mut(&mut self) -> &mut Store<TextResource>

Get a mutable reference to the entire store for the associated type

source§

fn idmap(&self) -> Option<&IdMap<TextResourceHandle>>

Get a reference to the id map for the associated type, mapping global ids to internal ids

source§

fn idmap_mut(&mut self) -> Option<&mut IdMap<TextResourceHandle>>

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids

source§

fn store_typeinfo() -> &'static str

source§

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.
source§

fn add(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern
source§

fn has(&self, item: impl Request<T>) -> bool

Returns true if the store has the item
source§

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity. Read more
source§

fn get(&self, item: impl Request<T>) -> Result<&T, StamError>

Get a reference to an item from the store This is a low-level API method, you usually want to use dedicated high-level methods like AnnotationStore::annotation() instead.
source§

fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID This is a low-level API method
source§

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed
source§

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle. Also works for temporary IDs if enabled. This is a low-level API method. You usually don’t want to call this directly.
source§

fn iter(&self) -> StoreIter<'_, T>
where T: Storable<StoreType = Self>,

Iterate over all items in the store This is a low-level API method, use dedicated high-level iterators like annotations(), resources() instead.
source§

fn iter_mut(&mut self) -> StoreIterMut<'_, T>

Iterate over the store, mutably This is a low-level API method.
source§

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store This is a low-level API method.
source§

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item This is a low-level API method.
source§

impl ToCsv for AnnotationStore
where Self: TypeInfo + Configurable,

source§

fn to_csv_writer<W>(&self, writer: W, table: CsvTable) -> Result<(), StamError>
where W: Write,

Writes CSV output, for the specified table, to the writer

source§

fn to_csv_file( &self, filename: &str, config: &Config, table: CsvTable ) -> Result<(), StamError>

Writes this structure to a file The actual dataformat can be set via config, the default is STAM JSON. Note: This only writes a single table! Just use [AnnotationStore.save()] to write everything.
source§

fn to_csv_string(&self, table: Option<CsvTable>) -> Result<String, StamError>

source§

impl ToJson for AnnotationStore

source§

fn to_json_writer<W>(&self, writer: W, compact: bool) -> Result<(), StamError>
where W: Write,

Writes a serialisation (choose a dataformat) to any writer Lower-level function
source§

fn to_json_file(&self, filename: &str, config: &Config) -> Result<(), StamError>

Writes this structure to a file The actual dataformat can be set via config, the default is STAM JSON.
source§

fn to_json_string(&self, config: &Config) -> Result<String, StamError>

Serializes this structure to one string. The actual dataformat can be set via config, the default is STAM JSON. If config not not specified, an attempt to fetch the AnnotationStore’s initial config is made
source§

impl TypeInfo for AnnotationStore

source§

fn typeinfo() -> Type

Return the type (introspection).
source§

fn temp_id_prefix() -> &'static str

Return the prefix for temporary identifiers of this type

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.

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.

§

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
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V