Struct genanki_rs::Package[][src]

pub struct Package { /* fields omitted */ }

Package to pack Decks and media_files and write them to a .apkg file

Example:

use genanki_rs::{Package, Deck, Note, Model, Field, Template};

let model = Model::new(
    1607392319,
    "Simple Model",
    vec![
        Field::new("Question"),
        Field::new("Answer"),
        Field::new("MyMedia"),
    ],
    vec![Template::new("Card 1")
        .qfmt("{{Question}}{{Question}}<br>{{MyMedia}}")
        .afmt(r#"{{FrontSide}}<hr id="answer">{{Answer}}"#)],
);

let mut deck = Deck::new(1234, "Example Deck", "Example Deck with media");
deck.add_note(Note::new(model.clone(), vec!["What is the capital of France?", "Paris", "[sound:sound.mp3]"])?);
deck.add_note(Note::new(model.clone(), vec!["What is the capital of France?", "Paris", r#"<img src="image.jpg">"#])?);

let mut package = Package::new(vec![my_deck], vec!["sound.mp3", "images/image.jpg"])?;
package.write_to_file("output.apkg")?;

Implementations

impl Package[src]

pub fn new(decks: Vec<Deck>, media_files: Vec<&str>) -> Result<Self, Error>[src]

Create a new package with decks and media_files

Returns Err if media_files are invalid

pub fn write_to_file(&mut self, file: &str) -> Result<(), Error>[src]

Writes the package to a file

Returns Err if the file cannot be created

pub fn write_to_file_timestamp(
    &mut self,
    file: &str,
    timestamp: f64
) -> Result<(), Error>
[src]

Writes the package to a file using a timestamp

Returns Err if the file cannot be created

Auto Trait Implementations

impl RefUnwindSafe for Package

impl Send for Package

impl Sync for Package

impl Unpin for Package

impl UnwindSafe for Package

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V