Skip to main content

TurnEvent

Enum TurnEvent 

Source
pub enum TurnEvent {
    FunctionCall {
        function_name: String,
        args: CallArgs,
        call_id: u32,
        object_id: Option<MontyUuid>,
        allow_eager_await: bool,
        position: SourceRange,
    },
    OsCall {
        function_name: String,
        args: CallArgs,
        call_id: u32,
        allow_eager_await: bool,
        system_sleep: Option<Duration>,
        position: SourceRange,
    },
    NameLookup {
        name: String,
        object_id: Option<MontyUuid>,
        position: SourceRange,
    },
    ResolveFutures {
        pending_call_ids: Vec<u32>,
        position: SourceRange,
    },
    Complete(MontyObject),
}
Expand description

How a protocol turn ended: a suspension that needs an answer from the caller, or completion of the fed snippet.

Variants§

§

FunctionCall

The sandbox called an external function — answer with Checkout::resume. When object_id is set this is a method call on a host-backed object, routed by uuid — a class instance, or a class type (a classmethod call, or construction of a host class, which is spelled __call__); the receiver is NOT included in args.

Fields

§function_name: String
§args: CallArgs

One arena holding every positional and keyword argument.

§call_id: u32
§object_id: Option<MontyUuid>
§allow_eager_await: bool

Coroutine results may be awaited and returned via Checkout::resume_futures.

§position: SourceRange

Where the call expression is in the source.

§

OsCall

The sandbox performed an OS operation (e.g. "Path.read_text"). Answer it from this feed’s mounts with Checkout::resume_from_mounts, or directly with Checkout::resume. A caller with no handler should resume with ResumeValue::NotHandled; the sandbox then raises the call’s own no-handler default.

Answer host imports from the caller’s modules before other handlers. OsFunctionCall::Import takes a module value; NotFound / NotHandled raise ModuleNotFoundError. OsFunctionCall::ImportStubs takes a dict of dotted module paths to .pyi source or None, or NotHandled for no stubs.

Fields

§function_name: String
§args: CallArgs

One arena holding every positional and keyword argument.

§call_id: u32
§allow_eager_await: bool

As on FunctionCall: the caller may await the wait and answer with Checkout::resume_futures. Only set on a call OsFunctionCall::accepts_future allows a future for.

§system_sleep: Option<Duration>

Wait this duration, then return MontyObject::none() (as a future for asyncio.sleep). The parent caps the untrusted worker’s delay and charges max_total_sleep before returning it. None delegates to the caller’s OS handler.

§position: SourceRange

Where the call expression is in the source.

§

NameLookup

The sandbox read an undefined name, or — when object_id is set — a lazy attribute on the host-backed object with that uuid (a class instance, or a class type) — answer with Checkout::resume_name_lookup. An Undefined (or None) answer raises NameError for plain lookups, AttributeError for attribute lookups; an Error answer raises the host’s exception in the sandbox.

Fields

§name: String
§object_id: Option<MontyUuid>
§position: SourceRange

Where the name (or attribute access) is in the source.

§

ResolveFutures

Every sandbox task is blocked on external futures — answer with Checkout::resume_futures.

Fields

§pending_call_ids: Vec<u32>
§position: SourceRange

Where the main task’s blocked await is in the source.

§

Complete(MontyObject)

The fed snippet completed with this value; the session is ready for the next Checkout::feed.

Trait Implementations§

Source§

impl Debug for TurnEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V