pub struct Engine<State = ()>{
pub state: Arc<State>,
pub type_system: TypeSystem,
pub heap: Heap,
/* private fields */
}Fields§
§state: Arc<State>§type_system: TypeSystem§heap: HeapImplementations§
Source§impl<State> Engine<State>
impl<State> Engine<State>
pub fn new(state: State) -> Self
pub fn with_prelude(state: State) -> Result<Self, EngineError>
pub fn with_options( state: State, options: EngineOptions, ) -> Result<Self, EngineError>
pub fn into_heap(self) -> Heap
pub fn cancellation_token(&self) -> CancellationToken
pub fn set_default_imports(&mut self, imports: Vec<String>)
pub fn default_imports(&self) -> &[String]
Sourcepub fn registry_markdown(&self) -> String
pub fn registry_markdown(&self) -> String
Return a markdown document that inventories the currently-registered engine state.
The report includes:
- summary counts
- libraries and exports
- ADTs
- functions/values in the type environment
- type classes, methods, and instances
- native implementations
§Examples
ⓘ
use rex_engine::Engine;
let engine = Engine::with_prelude(()).unwrap();
let md = engine.registry_markdown();
assert!(md.contains("# Engine Registry"));
assert!(md.contains("## ADTs"));pub fn cancel(&self)
pub fn inject_library( &mut self, library: Library<State>, ) -> Result<(), EngineError>
pub fn inject_rex_default_instance<T>(&mut self) -> Result<(), EngineError>where
T: RexType + RexDefault<State>,
pub fn adt_decl(&mut self, name: &str, params: &[&str]) -> AdtDecl
Sourcepub fn adt_decl_from_type(&mut self, typ: &Type) -> Result<AdtDecl, EngineError>
pub fn adt_decl_from_type(&mut self, typ: &Type) -> Result<AdtDecl, EngineError>
Seed an AdtDecl from a Rex type constructor.
Accepted shapes:
Type::con("Foo", 0)->Foowith no paramsFoo a b(where args are type vars) ->Foowith params inferred from varsType::con("Foo", n)(bare higher-kinded head) ->Foowith generated paramst0..t{n-1}
Sourcepub fn adt_decl_from_type_with_params(
&mut self,
typ: &Type,
params: &[&str],
) -> Result<AdtDecl, EngineError>
pub fn adt_decl_from_type_with_params( &mut self, typ: &Type, params: &[&str], ) -> Result<AdtDecl, EngineError>
Same as adt_decl_from_type, but uses explicit parameter names.
pub fn inject_instance(&mut self, class: &str, inst: Instance)
Source§impl<State> Engine<State>
impl<State> Engine<State>
pub fn add_resolver<F>(&mut self, name: impl Into<String>, f: F)where
F: Fn(ResolveRequest) -> Result<Option<ResolvedLibrary>, EngineError> + Send + Sync + 'static,
pub fn add_default_resolvers(&mut self)
pub fn add_include_resolver( &mut self, root: impl AsRef<Path>, ) -> Result<(), EngineError>
pub fn infer_library_file( &mut self, path: impl AsRef<Path>, gas: &mut GasMeter, ) -> Result<(Vec<Predicate>, Type), CompileError>
pub fn infer_snippet( &mut self, source: &str, gas: &mut GasMeter, ) -> Result<(Vec<Predicate>, Type), CompileError>
pub fn infer_snippet_at( &mut self, source: &str, importer_path: impl AsRef<Path>, gas: &mut GasMeter, ) -> Result<(Vec<Predicate>, Type), CompileError>
Trait Implementations§
Auto Trait Implementations§
impl<State> Freeze for Engine<State>
impl<State = ()> !RefUnwindSafe for Engine<State>
impl<State> Send for Engine<State>
impl<State> Sync for Engine<State>
impl<State> Unpin for Engine<State>
impl<State> UnsafeUnpin for Engine<State>
impl<State = ()> !UnwindSafe for Engine<State>
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