Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

A loaded-map cache bound to a load path. Interscript.transliterate parity: transliterate(map_id, string) runs stage main.

Implementations§

Source§

impl Runtime

Source

pub fn new(load_path: Vec<PathBuf>) -> Runtime

Examples found in repository?
examples/dbg-run.rs (lines 5-8)
4fn main() {
5    let rt = Runtime::new(vec![
6        "../maps/maps".into(),
7        "../maps/libs".into(),
8    ]);
9    let doc = rt.load("alalc-ben-Beng-Latn-2017").unwrap();
10    println!("deps declared: {:?}", doc.dep_aliases.keys().collect::<Vec<_>>());
11    for (name, stage) in &doc.stages {
12        for item in &stage.items {
13            if let StageItem::Run { dep, stage, .. } = item {
14                println!("stage {name}: run dep={dep:?} stage={stage:?}");
15            }
16        }
17    }
18    let un = rt.load("un-ben-Beng-Latn-2016").unwrap();
19    let out = interscript_rs::interpreter::execute_stage_pub(&un, "main", "ত্য", None);
20    println!("un-ben direct: {:?}", out);
21}
Source

pub fn load(&self, map_id: &str) -> Result<Rc<Document>>

Load (and dependency-close) a map document.

Examples found in repository?
examples/dbg-run.rs (line 9)
4fn main() {
5    let rt = Runtime::new(vec![
6        "../maps/maps".into(),
7        "../maps/libs".into(),
8    ]);
9    let doc = rt.load("alalc-ben-Beng-Latn-2017").unwrap();
10    println!("deps declared: {:?}", doc.dep_aliases.keys().collect::<Vec<_>>());
11    for (name, stage) in &doc.stages {
12        for item in &stage.items {
13            if let StageItem::Run { dep, stage, .. } = item {
14                println!("stage {name}: run dep={dep:?} stage={stage:?}");
15            }
16        }
17    }
18    let un = rt.load("un-ben-Beng-Latn-2016").unwrap();
19    let out = interscript_rs::interpreter::execute_stage_pub(&un, "main", "ত্য", None);
20    println!("un-ben direct: {:?}", out);
21}
Source

pub fn transliterate(&self, map_id: &str, input: &str) -> Result<String>

Interscript.transliterate(map_id, string).

Source

pub fn transliterate_lang( &self, map_id: &str, input: &str, language: Option<&str>, ) -> Result<String>

ISC-WF-1 W3: transliterate with a language selection (§5.1). Selecting a language the map does not declare behaves like no selection (every when guard inert).

Source

pub fn transliterate_stage( &self, map_id: &str, stage: &str, input: &str, language: Option<&str>, ) -> Result<String>

Source

pub fn run_tests(&self, map_id: &str) -> Result<(usize, usize, Vec<String>)>

Run a document’s embedded tests; returns (passed, failed, failures). Embedded tests run WITHOUT a language selection (§5.1 default).

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.