Skip to main content

PreparedBackendRequest

Struct PreparedBackendRequest 

Source
pub struct PreparedBackendRequest<'a, B: SandboxBackend> { /* private fields */ }
Expand description

A request that passed backend capability preflight.

This type is still portable and contains no process handle. Native backend code may lower it to an OS-specific launch request after applying the filesystem, network, environment, and lifecycle contracts.

The B type parameter is a type-level binding to the backend whose capabilities were checked during preparation. The handoff also stores a runtime BackendIdentity, so every accessor verifies the exact backend instance that was checked. Native lowering should accept PreparedBackendRequest<'_, Self> and pass the same backend instance to its accessors.

use cageforge_backend_api::{
    BackendCapabilities, BackendIdentity, PreparedBackendRequest, SandboxBackend,
};

struct LinuxBackend(BackendIdentity);
struct WindowsBackend(BackendIdentity);

impl SandboxBackend for LinuxBackend {
    fn identity(&self) -> &BackendIdentity {
        &self.0
    }

    fn capabilities(&self) -> BackendCapabilities {
        BackendCapabilities::new()
    }
}

impl SandboxBackend for WindowsBackend {
    fn identity(&self) -> &BackendIdentity {
        &self.0
    }

    fn capabilities(&self) -> BackendCapabilities {
        BackendCapabilities::new()
    }
}

fn take_linux<'a>(_: PreparedBackendRequest<'a, LinuxBackend>) {}

fn pass_windows_to_linux<'a>(prepared: PreparedBackendRequest<'a, WindowsBackend>) {
    take_linux(prepared);
}

Implementations§

Source§

impl<'a, B: SandboxBackend> PreparedBackendRequest<'a, B>

Source

pub fn command_spec( &self, backend: &B, ) -> Result<&'a CommandSpec, BackendContractError>

Returns the validated executable and argv values.

The working directory is intentionally exposed separately through Self::working_directory. A backend must not recover or inherit the original optional cwd from a raw CommandRequest after preflight.

Source

pub fn sandbox( &self, backend: &B, ) -> Result<&'a EffectiveSandbox, BackendContractError>

Returns the validated effective sandbox.

Source

pub fn filesystem_lowering( &self, backend: &B, ) -> Result<EffectiveFilesystemLowering<'_>, BackendContractError>

Returns all filesystem constraint layers required for native lowering.

The backend must enforce every layer in the returned view. This is distinct from the combined decision helpers: a native sandbox builder needs the concrete rules, protected paths, and glob settings, while the view prevents it from selecting only the requested or ceiling side.

Source

pub fn network_lowering( &self, backend: &B, ) -> Result<EffectiveNetworkLowering<'_>, BackendContractError>

Returns all network constraint layers required for native lowering.

These rules configure enforcement only. Actual connections must still use Self::authorize_connection with a resolved target and exact socket address.

Source

pub fn path_context( &self, backend: &B, ) -> Result<&EffectivePathContext, BackendContractError>

Returns the runtime path context that was narrowed and checked during BackendRequest::prepare_for.

Source

pub fn working_directory( &self, backend: &B, ) -> Result<&Path, BackendContractError>

Returns the effective working directory resolved during preflight.

This is always present. When the command did not specify an explicit directory, it is the runtime current directory supplied in the path context and checked against the effective filesystem policy.

Source

pub fn stdio(&self, backend: &B) -> Result<StdioSpec, BackendContractError>

Returns the validated standard-stream routing.

Source

pub fn timeout_policy( &self, backend: &B, ) -> Result<TimeoutPolicy, BackendContractError>

Returns the validated timeout intent.

Source

pub fn apply_environment( &self, backend: &B, input: EnvironmentInput, ) -> Result<BTreeMap<OsString, OsString>, BackendContractError>

Applies the effective environment to a backend-selected input base.

A backend must construct EnvironmentInput::core only after it has selected the platform’s conservative core environment.

Source

pub fn filesystem_access_for_path( &self, backend: &B, path: &Path, ) -> Result<FilesystemDecision, BackendContractError>

Evaluates one absolute path against both effective filesystem policies.

Source

pub fn filesystem_access_for( &self, backend: &B, selector: &PathSelector, ) -> Result<FilesystemDecision, BackendContractError>

Evaluates one symbolic filesystem selector against both effective policies and the narrowed runtime context.

The context must come from Self::path_context. A selector that has no effective runtime paths is denied, so a backend cannot accidentally replace a workspace-root ceiling with a broader context.

Source

pub fn network_decision_for_domain_with_resolved_ips( &self, backend: &B, domain: &str, resolved_ips: &[IpAddr], ) -> Result<NetworkDecision, BackendContractError>

Evaluates a resolved hostname and all addresses captured for it.

This is a policy query, not connection authorization. A backend must call Self::authorize_connection immediately before connecting.

Source

pub fn authorize_connection( &self, backend: &B, target: &ResolvedNetworkTarget, connected: SocketAddr, ) -> Result<ConnectionAuthorization, BackendContractError>

Authorizes the exact socket address the backend is about to connect to.

Source

pub fn network_decision_for_unix_socket( &self, backend: &B, socket: &Path, ) -> Result<NetworkDecision, BackendContractError>

Evaluates one Unix socket path against both effective network policies.

Trait Implementations§

Source§

impl<'a, B: SandboxBackend> Clone for PreparedBackendRequest<'a, B>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, B: SandboxBackend> Debug for PreparedBackendRequest<'a, B>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, B> Freeze for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: Freeze,

§

impl<'a, B> RefUnwindSafe for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: RefUnwindSafe,

§

impl<'a, B> Send for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: Send,

§

impl<'a, B> Sync for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: Sync,

§

impl<'a, B> Unpin for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: Unpin,

§

impl<'a, B> UnsafeUnpin for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: UnsafeUnpin,

§

impl<'a, B> UnwindSafe for PreparedBackendRequest<'a, B>
where PhantomData<fn() -> B>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.