Struct forne::Forne

source ·
pub struct Forne { /* private fields */ }
Expand description

A Forne engine, which can act as the backend for learn operations. An instance of this struct should be instantiated with a Set to operate on and an operation to perform.

The engine has the same lifetime as the reference it is given to its interface for communicating with the host environment.

Implementations§

source§

impl Forne

source

pub fn new_set( src: String, adapter_script: &str, raw_method: RawMethod ) -> Result<Self>

Creates a new set from the given source file text and adapter script. This is a thin wrapper over the Set::new_with_adapter method, abstracting away the internal use of a Rhai engine. In general, you should prefer this method, as there is no additional overhead to using it.

source

pub fn update( &mut self, src: String, adapter_script: &str, raw_method: RawMethod ) -> Result<()>

Updates the given set from a source. See Set::update_with_adapter for the exact behaviour of this method.

source

pub fn from_set(set: Set) -> Self

Creates a new Forne engine. While not inherently expensive, this should generally only be called once, or when the system needs to restart.

source

pub fn learn(&mut self, raw_method: RawMethod) -> Result<Driver<'_, '_>>

Start a new learning session with this instance and the given method (see RawMethod), creating a Driver to run it.

Errors

This will return an error if the given method has not previously been used with this set, and a reset must be performed in that case, which will lead to the loss of previous progress, unless a transformer is used.

source

pub fn test(&mut self) -> Driver<'_, '_>

Start a new test with this instance, creating a Driver to run it.

source

pub fn save_set(&self) -> Result<String>

Saves this set to JSON.

Errors

This can only possible fail if the learning method produces metadata that cannot be serialized into JSON.

source

pub fn reset_learn(&mut self, method: RawMethod) -> Result<()>

Resets all cards in a learn session back to the default metadata values prescribed by the learning method.

source

pub fn reset_test(&mut self)

Resets all test progress for this set. This is irreversible!

This will not change whether or not cards are starred.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Forne

§

impl Send for Forne

§

impl Sync for Forne

§

impl Unpin for Forne

§

impl !UnwindSafe for Forne

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V