pub struct TextResourceBuilder { /* private fields */ }Expand description
This is a helper structure to build TextResource instances in a builder pattern.
This structure can be passed to AnnotationStore::add_resource() or AnnotationStore::with_resource().
Example:
use stam::*;
let mut store = AnnotationStore::default();
store.add_resource(
TextResourceBuilder::new()
.with_id("testres")
.with_text("Hello world!")
);Implementations§
Source§impl TextResourceBuilder
impl TextResourceBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Instantiate a new TextResourceBuilder.
You likely want to pass the result to AnnotationStore::add_resource().
Sourcepub fn with_id(self, id: impl Into<String>) -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
Associate a public identifier with the resource
Sourcepub fn with_filename(self, filename: impl Into<String>) -> Self
pub fn with_filename(self, filename: impl Into<String>) -> Self
Set the filename associated with the resource.
If not ID and no text is give, the resource will be loaded from this file.
It is assumed to be either STAM JSON (.json extension) or plain text.
Trait Implementations§
Source§impl Debug for TextResourceBuilder
impl Debug for TextResourceBuilder
Source§impl Default for TextResourceBuilder
impl Default for TextResourceBuilder
Source§fn default() -> TextResourceBuilder
fn default() -> TextResourceBuilder
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TextResourceBuilder
impl<'de> Deserialize<'de> for TextResourceBuilder
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TextResourceBuilder
impl RefUnwindSafe for TextResourceBuilder
impl Send for TextResourceBuilder
impl Sync for TextResourceBuilder
impl Unpin for TextResourceBuilder
impl UnwindSafe for TextResourceBuilder
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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