pub struct RuntimeManager<R>{ /* private fields */ }
Expand description
运行时管理器
- 🎯在一个数据结构中封装「虚拟机运行时」与「配置信息」
- 📌只负责单个运行时的运行管理
- 🚩不负责「终止、重启运行时」等过程
Implementations§
Source§impl<R> RuntimeManager<R>
impl<R> RuntimeManager<R>
Sourcepub fn new(runtime: R, config: RuntimeConfig) -> Self
pub fn new(runtime: R, config: RuntimeConfig) -> Self
构造函数
- 🎯由此接管虚拟机实例、配置的所有权
Sourcepub fn manage(&mut self) -> Result<Result<()>>
pub fn manage(&mut self) -> Result<Result<()>>
【主函数】在运行时启动后,对其进行管理
- 🎯健壮性:更多「警告/重来」而非
panic
- 🎯用户友好:尽可能隐藏底层内容
- 如错误堆栈
- 📌主要逻辑
.nal
脚本预加载- 用户的运行时交互
- Websocket服务端
- 🚩【2024-04-03 00:33:41】返回的
Result
作为程序的终止码Ok(Ok(..))
⇒ 程序正常终止Ok(Err(..))
⇒ 程序异常终止Err(..)
⇒ 程序异常中断
Sourcepub fn prelude_nal(&mut self) -> ControlFlow<Result<()>, Result<()>>
pub fn prelude_nal(&mut self) -> ControlFlow<Result<()>, Result<()>>
Sourcepub fn spawn_read_output(&mut self) -> Result<JoinHandle<Result<()>>>
pub fn spawn_read_output(&mut self) -> Result<JoinHandle<Result<()>>>
生成「读取输出」子线程
Sourcepub fn try_spawn_ws_server(&mut self) -> Result<Option<JoinHandle<Result<()>>>>
pub fn try_spawn_ws_server(&mut self) -> Result<Option<JoinHandle<Result<()>>>>
生成「Websocket服务」子线程
Sourcepub fn spawn_user_input(&mut self) -> Result<JoinHandle<Result<()>>>
pub fn spawn_user_input(&mut self) -> Result<JoinHandle<Result<()>>>
生成「用户输入」子线程
Sourcepub fn input_line_to_vm(
runtime: &mut R,
line: &str,
config: &RuntimeConfig,
output_cache: &mut OutputCache,
nal_root_path: &Path,
) -> Result<()>
pub fn input_line_to_vm( runtime: &mut R, line: &str, config: &RuntimeConfig, output_cache: &mut OutputCache, nal_root_path: &Path, ) -> Result<()>
置入一行输入
- 📄
nal_root_path
:从NAL文件加载⇒NAL文件所在路径;用户输入⇒配置文件所在路径
Trait Implementations§
Source§impl<R> Clone for RuntimeManager<R>
impl<R> Clone for RuntimeManager<R>
Source§fn clone(&self) -> RuntimeManager<R>
fn clone(&self) -> RuntimeManager<R>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<R> Freeze for RuntimeManager<R>
impl<R> RefUnwindSafe for RuntimeManager<R>
impl<R> Send for RuntimeManager<R>
impl<R> Sync for RuntimeManager<R>
impl<R> Unpin for RuntimeManager<R>
impl<R> UnwindSafe for RuntimeManager<R>
Blanket Implementations§
Source§impl<T> BoostWithOption for T
impl<T> BoostWithOption for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more