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 data(&self) -> &Vec<AnnotationDataBuilder<'a>>
pub fn target(&self) -> Option<&SelectorBuilder<'a>>
sourcepub fn with_id(self, id: impl Into<String>) -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
Set an explicit ID. If you want to generate a random one, pass the result of generate_id() to the first parameter.
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
Trait Implementations§
source§impl<'a> Debug for AnnotationBuilder<'a>
impl<'a> Debug for AnnotationBuilder<'a>
source§impl<'a> Default for AnnotationBuilder<'a>
impl<'a> Default for AnnotationBuilder<'a>
source§impl<'de, 'a> Deserialize<'de> for AnnotationBuilder<'a>
impl<'de, 'a> Deserialize<'de> for AnnotationBuilder<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<'a> Freeze for AnnotationBuilder<'a>
impl<'a> RefUnwindSafe for AnnotationBuilder<'a>
impl<'a> Send for AnnotationBuilder<'a>
impl<'a> Sync for AnnotationBuilder<'a>
impl<'a> Unpin for AnnotationBuilder<'a>
impl<'a> UnwindSafe for AnnotationBuilder<'a>
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
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