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
impl Forne
sourcepub fn new_set(
src: String,
adapter_script: &str,
raw_method: RawMethod
) -> Result<Self>
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.
sourcepub fn update(
&mut self,
src: String,
adapter_script: &str,
raw_method: RawMethod
) -> Result<()>
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.
sourcepub fn from_set(set: Set) -> Self
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.
sourcepub fn learn(&mut self, raw_method: RawMethod) -> Result<Driver<'_, '_>>
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.
sourcepub fn test(&mut self) -> Driver<'_, '_>
pub fn test(&mut self) -> Driver<'_, '_>
Start a new test with this instance, creating a Driver
to run it.
sourcepub fn save_set(&self) -> Result<String>
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.
sourcepub fn reset_learn(&mut self, method: RawMethod) -> Result<()>
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.
sourcepub fn reset_test(&mut self)
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.