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.
See the top-level documentation for AnnotationStore for a complete usage example.
Implementations§
source§impl<'a> AnnotationBuilder<'a>
impl<'a> AnnotationBuilder<'a>
pub fn new() -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
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,
dataset: impl Into<BuildItem<'a, AnnotationDataSet>>,
key: impl Into<BuildItem<'a, DataKey>>,
value: impl Into<DataValue>
) -> Self
pub fn with_data( self, dataset: impl Into<BuildItem<'a, AnnotationDataSet>>, key: impl Into<BuildItem<'a, DataKey>>, value: impl Into<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: impl Into<BuildItem<'a, AnnotationDataSet>>,
key: impl Into<BuildItem<'a, DataKey>>,
value: impl Into<DataValue>,
id: impl Into<BuildItem<'a, AnnotationData>>
) -> Self
pub fn with_data_with_id( self, dataset: impl Into<BuildItem<'a, AnnotationDataSet>>, key: impl Into<BuildItem<'a, DataKey>>, value: impl Into<DataValue>, id: impl Into<BuildItem<'a, AnnotationData>> ) -> Self
Use this method instead of Self::with_data() if you want to assign a public identifier (last argument)
sourcepub fn with_existing_data(
self,
dataset: impl Into<BuildItem<'a, AnnotationDataSet>>,
annotationdata: impl Into<BuildItem<'a, AnnotationData>>
) -> Self
pub fn with_existing_data( self, dataset: impl Into<BuildItem<'a, AnnotationDataSet>>, annotationdata: impl Into<BuildItem<'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