pub struct Note { /* private fields */ }
Expand description
Represents a note in Anki
Implementations§
Source§impl Note
impl Note
Sourcepub fn new(
model: Model,
field_values: HashMap<String, String>,
tags: HashSet<String>,
media: Vec<FieldMedia>,
) -> Result<Self, NoteError>
pub fn new( model: Model, field_values: HashMap<String, String>, tags: HashSet<String>, media: Vec<FieldMedia>, ) -> Result<Self, NoteError>
Creates a new note with validation
Sourcepub fn with_id(
id: NoteId,
model: Model,
field_values: HashMap<String, String>,
tags: HashSet<String>,
media: Vec<FieldMedia>,
) -> Result<Self, NoteError>
pub fn with_id( id: NoteId, model: Model, field_values: HashMap<String, String>, tags: HashSet<String>, media: Vec<FieldMedia>, ) -> Result<Self, NoteError>
Creates a note with an existing ID (for notes retrieved from Anki)
Sourcepub fn field_values(&self) -> &HashMap<String, String>
pub fn field_values(&self) -> &HashMap<String, String>
Gets the field values of this note
Sourcepub fn field_value(&self, field_name: &str) -> Option<&String>
pub fn field_value(&self, field_name: &str) -> Option<&String>
Gets a specific field value
Gets all tags on this note
Sourcepub fn media(&self) -> &[FieldMedia]
pub fn media(&self) -> &[FieldMedia]
Gets media attached to this note
Sourcepub fn update_field(
&mut self,
field_name: &str,
value: String,
) -> Result<(), NoteError>
pub fn update_field( &mut self, field_name: &str, value: String, ) -> Result<(), NoteError>
Updates a field value
Sourcepub fn remove_tag(&mut self, tag: &str) -> bool
pub fn remove_tag(&mut self, tag: &str) -> bool
Removes a tag
Sourcepub fn add_media(
&mut self,
field_name: &str,
media: Media,
) -> Result<(), NoteError>
pub fn add_media( &mut self, field_name: &str, media: Media, ) -> Result<(), NoteError>
Adds media to a field
Sourcepub fn front_value(&self) -> Option<&String>
pub fn front_value(&self) -> Option<&String>
Gets the value for the front (question) field
Sourcepub fn back_value(&self) -> Option<&String>
pub fn back_value(&self) -> Option<&String>
Gets the value for the back (answer) field
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Note
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnwindSafe for Note
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