Skip to main content

rune/runtime/
mod.rs

1//! Runtime module for Rune.
2
3#[cfg(test)]
4mod tests;
5
6#[macro_use]
7mod macros;
8
9mod steps_between;
10use self::steps_between::StepsBetween;
11
12mod dynamic;
13pub use self::dynamic::{DynamicEmpty, DynamicStruct, DynamicTuple};
14
15mod access;
16pub use self::access::AccessError;
17pub(crate) use self::access::{Access, RawAccessGuard, Snapshot};
18
19mod borrow_mut;
20pub use self::borrow_mut::BorrowMut;
21
22mod borrow_ref;
23pub use self::borrow_ref::BorrowRef;
24
25mod any_obj_vtable;
26use self::any_obj_vtable::AnyObjVtable;
27
28mod any_obj;
29pub use self::any_obj::{AnyObj, AnyObjError};
30use self::any_obj::{AnyObjData, AnyObjErrorKind};
31pub(crate) use self::any_obj::{AnyObjDrop, RawAnyObjGuard};
32
33mod shared;
34pub use self::shared::Shared;
35
36mod args;
37pub use self::args::{Args, FixedArgs};
38pub(crate) use self::args::{DynArgs, DynArgsUsed, DynGuardedArgs};
39
40mod awaited;
41pub(crate) use self::awaited::Awaited;
42
43pub mod budget;
44
45mod bytes;
46pub use self::bytes::{bytes_slice_index_get, Bytes};
47
48mod call;
49pub use self::call::Call;
50
51mod const_value;
52#[doc(hidden)]
53pub use self::const_value::ToConstValue;
54pub use self::const_value::{
55    from_const_value, to_const_value, ConstConstruct, ConstConstructImpl, ConstValue,
56    FromConstValue,
57};
58pub(crate) use self::const_value::{
59    ConstContext, ConstInstance, ConstValueKind, EmptyConstContext,
60};
61
62pub mod debug;
63pub use self::debug::{DebugGlobal, DebugInfo, DebugInst};
64
65mod env;
66
67pub mod format;
68pub use self::format::{Format, FormatSpec};
69
70mod from_value;
71pub use self::from_value::{from_value, FromValue, UnsafeToMut, UnsafeToRef};
72
73mod function;
74pub use self::function::{Function, SyncFunction};
75
76mod future;
77pub use self::future::Future;
78pub(crate) use self::future::SelectFuture;
79
80mod globals;
81pub use self::globals::{Globals, GlobalsError};
82
83pub(crate) mod generator;
84pub use self::generator::Generator;
85
86mod generator_state;
87pub use self::generator_state::GeneratorState;
88
89mod guarded_args;
90pub use self::guarded_args::GuardedArgs;
91
92pub(crate) mod into_output;
93pub use self::into_output::IntoOutput;
94
95pub(crate) mod inst;
96pub use self::inst::{Address, Inst, Output};
97pub(crate) use self::inst::{
98    InstArithmeticOp, InstBitwiseOp, InstOp, InstRange, InstShiftOp, InstTarget, InstValue,
99    PanicReason,
100};
101
102mod iterator;
103pub use self::iterator::Iterator;
104
105mod r#type;
106pub use self::r#type::Type;
107
108mod label;
109pub use self::label::DebugLabel;
110pub(crate) use self::label::Label;
111
112pub(crate) mod object;
113pub use self::object::Object;
114
115mod panic;
116pub(crate) use self::panic::{BoxedPanic, Panic};
117
118mod protocol;
119pub use self::protocol::Protocol;
120
121mod protocol_caller;
122pub(crate) use self::protocol_caller::{EnvProtocolCaller, ProtocolCaller};
123
124pub(crate) mod range_from;
125pub use self::range_from::RangeFrom;
126
127mod range_full;
128pub use self::range_full::RangeFull;
129
130mod range_to_inclusive;
131pub use self::range_to_inclusive::RangeToInclusive;
132
133mod range_to;
134pub use self::range_to::RangeTo;
135
136pub(crate) mod range_inclusive;
137pub use self::range_inclusive::RangeInclusive;
138
139pub(crate) mod range;
140pub use self::range::Range;
141
142mod runtime_context;
143pub use self::runtime_context::RuntimeContext;
144
145mod select;
146pub(crate) use self::select::Select;
147
148mod r#ref;
149use self::r#ref::RefVtable;
150pub use self::r#ref::{Mut, RawAnyGuard, Ref};
151
152mod memory;
153pub use self::memory::{Memory, SliceError, Stack, StackError, StoreError};
154pub(crate) use self::memory::{Pair, StoreErrorKind};
155
156mod static_string;
157pub use self::static_string::StaticString;
158
159mod stream;
160pub use self::stream::Stream;
161
162mod to_value;
163#[doc(hidden)]
164pub use self::to_value::ToValue;
165pub use self::to_value::{to_value, IntoReturn, UnsafeToValue};
166
167mod tuple;
168pub use self::tuple::{OwnedTuple, Tuple};
169
170mod type_info;
171pub use self::type_info::{AnyTypeInfo, TypeInfo};
172
173mod type_of;
174pub use self::type_of::{MaybeTypeOf, TypeHash, TypeOf};
175
176pub mod unit;
177pub(crate) use self::unit::UnitFn;
178pub use self::unit::{Unit, UnitStorage};
179
180mod value;
181pub use self::value::{
182    Accessor, EmptyStruct, Inline, RawValueGuard, Rtti, Struct, TupleStruct, TypeValue, Value,
183    ValueMutGuard, ValueRefGuard,
184};
185pub(crate) use self::value::{AnySequence, AnySequenceTakeError, Repr, RttiKind};
186
187pub mod slice;
188
189mod vec;
190pub use self::vec::Vec;
191
192mod vec_tuple;
193pub use self::vec_tuple::VecTuple;
194
195mod vm;
196use self::vm::CallResultOnly;
197pub use self::vm::{CallFrame, Isolated, Vm};
198
199mod vm_call;
200pub(crate) use self::vm_call::VmCall;
201
202pub(crate) mod vm_diagnostics;
203pub use self::vm_diagnostics::VmDiagnostics;
204pub(crate) use self::vm_diagnostics::VmDiagnosticsObj;
205
206mod vm_error;
207#[cfg(feature = "emit")]
208pub(crate) use self::vm_error::VmErrorAt;
209#[allow(deprecated)]
210pub use self::vm_error::VmResult;
211pub use self::vm_error::{ExpectedType, RuntimeError, VmError};
212pub(crate) use self::vm_error::{VmErrorKind, VmIntegerRepr};
213
214mod vm_execution;
215pub(crate) use self::vm_execution::ExecutionState;
216pub use self::vm_execution::{VmExecution, VmOutcome, VmResume, VmSendExecution};
217
218mod vm_halt;
219pub(crate) use self::vm_halt::{VmHalt, VmHaltInfo};
220
221mod fmt;
222pub use self::fmt::Formatter;
223
224mod control_flow;
225pub use self::control_flow::ControlFlow;
226
227mod hasher;
228pub use self::hasher::Hasher;
229
230crate::declare_dyn_fn! {
231    struct FunctionHandlerVTable;
232
233    /// A function handler.
234    pub struct FunctionHandler {
235        fn call(memory: &mut dyn Memory, addr: Address, count: usize, out: Output) -> Result<(), VmError>;
236    }
237}
238
239pub(crate) type FieldMap<K, V> = crate::alloc::HashMap<K, V>;
240
241#[inline(always)]
242pub(crate) fn new_field_map<K, V>() -> FieldMap<K, V> {
243    FieldMap::new()
244}
245
246#[inline(always)]
247pub(crate) fn new_field_hash_map_with_capacity<K, V>(
248    cap: usize,
249) -> crate::alloc::Result<FieldMap<K, V>> {
250    FieldMap::try_with_capacity(cap)
251}