Struct stam::AnnotationBuilder
source · pub struct AnnotationBuilder<'a> { /* private fields */ }Expand description
This is the builder that builds Annotation. The actual building is done by passing this structure to AnnotationStore::annotate(), there is no build() method for this builder.
Implementations§
source§impl<'a> AnnotationBuilder<'a>
impl<'a> AnnotationBuilder<'a>
pub fn new() -> Self
pub fn with_id(self, id: String) -> Self
sourcepub fn with_selector(self, selector: Selector) -> Self
pub fn with_selector(self, selector: Selector) -> Self
Sets the annotation target using an already existing selector
Use [Self.with_target()] or one of the target_ shortcut methods instead if you still need to build the target selector
sourcepub fn with_target(self, selector: SelectorBuilder<'a>) -> Self
pub fn with_target(self, selector: SelectorBuilder<'a>) -> Self
Set the target to be a crate::resources::TextResource. Creates a Selector::ResourceSelector
Sets the annotation target. Instantiates a new selector. Use [Self.with_target()] instead if you already have
a selector. Under the hood, this will invoke select() to obtain a selector.
sourcepub fn with_data(
self,
annotationset: Item<'a, AnnotationDataSet>,
key: Item<'a, DataKey>,
value: DataValue
) -> Self
pub fn with_data( self, annotationset: Item<'a, AnnotationDataSet>, key: Item<'a, DataKey>, value: DataValue ) -> Self
Associate data with the annotation.
If you provide a public key ID that does not exist yet, it’s crate::DataKey will be created.
You may use this (and similar methods) multiple times. Do note that multiple data associated with the same annotation is considered inter-dependent, use multiple annotations instead if each it interpretable independent of the others.
sourcepub fn with_data_with_id(
self,
dataset: Item<'a, AnnotationDataSet>,
key: Item<'a, DataKey>,
value: DataValue,
id: Item<'a, AnnotationData>
) -> Self
pub fn with_data_with_id( self, dataset: Item<'a, AnnotationDataSet>, key: Item<'a, DataKey>, value: DataValue, id: Item<'a, AnnotationData> ) -> Self
Use this method instead of Self::with_data() if you want to assign a public identifier (last argument)
sourcepub fn with_data_by_id(
self,
dataset: Item<'a, AnnotationDataSet>,
id: Item<'a, AnnotationData>
) -> Self
pub fn with_data_by_id( self, dataset: Item<'a, AnnotationDataSet>, id: Item<'a, AnnotationData> ) -> Self
This references existing AnnotationData, in a particular [`AnnotationDataSet’], by Id.
Useful if you have an Id or reference instance already.
sourcepub fn with_data_builder(self, builder: AnnotationDataBuilder<'a>) -> Self
pub fn with_data_builder(self, builder: AnnotationDataBuilder<'a>) -> Self
Lower level method if you want to create and pass [`AnnotationDataBuilder’] yourself rather than use the other with_data_*() shortcut methods.
sourcepub fn from_json_file(
filename: &str,
config: &Config
) -> Result<Self, StamError>
pub fn from_json_file( filename: &str, config: &Config ) -> Result<Self, StamError>
Reads a single annotation in STAM JSON from file
sourcepub fn from_json_str(string: &str) -> Result<Self, StamError>
pub fn from_json_str(string: &str) -> Result<Self, StamError>
Reads a single annotation in STAM JSON from string