Skip to main content

OnionLambdaRunnableLauncher

Struct OnionLambdaRunnableLauncher 

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

Lambda 启动器。

负责将 Lambda 对象与参数、约束、捕获等进行动态绑定, 并自动处理参数展开、约束检查、runnable 构造与映射等复杂流程。

§字段说明

  • lambda:被调用的 Lambda 对象(OnionObject::Lambda)
  • lambda_ref:Lambda 定义的强引用
  • lambda_self_object:Lambda 的 self 对象
  • argument:原始参数对象(用于参数展开)
  • flatten_argument:展平后的参数列表
  • string_pool:参数名字符串池,保证参数名唯一性与高效查找
  • current_argument_index:当前参数处理进度
  • runnable_mapper:对生成的 runnable 进行包装/变换的回调

Implementations§

Source§

impl OnionLambdaRunnableLauncher

Source

pub fn new<F>( lambda: &OnionObject, argument: OnionStaticObject, runnable_mapper: F, ) -> Result<OnionLambdaRunnableLauncher, RuntimeError>
where F: Fn(Box<dyn Runnable>) -> Result<Box<dyn Runnable>, RuntimeError> + Sync + Send + 'static,

构造新的 Lambda 启动器。

§参数
  • lambda:被调用的 Lambda 对象(OnionObject::Lambda)
  • argument:参数对象(可为元组、字典等)
  • runnable_mapper:对生成的 runnable 进行包装/变换的回调
§返回值

返回新的 OnionLambdaRunnableLauncher 实例,参数已自动展开,约束待校验

§细节说明
  • string_pool 由被调用 Lambda 决定,保证参数名唯一性
  • 参数展开失败或类型不符会直接返回错误
  • runnable_mapper 可用于包装异步、同步等调度器

Trait Implementations§

Source§

impl Runnable for OnionLambdaRunnableLauncher

Source§

fn receive( &mut self, step_result: &StepResult, _gc: &mut GC<OnionObjectCell>, ) -> Result<(), RuntimeError>

接收子任务的执行结果。

  • StepResult::Continue:参数约束校验通过,继续
  • StepResult::Return:布尔约束校验,false 则报错
  • 其他类型(NewRunnable/ReplaceRunnable/SpawnRunnable):均为非法,直接报错
  • StepResult::Error:直接转发错误
Source§

fn step(&mut self, gc: &mut GC<OnionObjectCell>) -> StepResult

推进参数约束校验与 runnable 构造。

  • 首先依次校验所有参数约束(布尔/嵌套 Lambda)
    • 若为布尔约束且为 false,立即报错
    • 若为 Lambda 约束,递归生成新 Launcher 进行校验
    • 其他类型直接报错
  • 所有约束校验通过后,收集参数,调用 lambda_ref.create_runnable 构造 runnable
  • 通过 runnable_mapper 包装后,替换当前 runnable
Source§

fn format_context(&self) -> String

格式化当前 Launcher 的上下文信息。

输出当前参数处理进度、Lambda 信息等,便于调试。

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.