Skip to main content

ObjectProvider

Trait ObjectProvider 

Source
pub trait ObjectProvider {
    type Object: WipObject;

    // Required method
    fn with_object<R>(
        &self,
        context: &ExecutionContext,
        path: &str,
        operation: impl FnOnce(&PublishedObject<Self::Object>) -> R,
    ) -> ProviderResult<R>;

    // Provided methods
    fn execute_operation(
        &self,
        context: &ExecutionContext,
        path: &str,
        operation: impl FnOnce(&PublishedObject<Self::Object>) -> OperationAttempt,
    ) -> ProviderResult<OperationAttempt> { ... }
    fn authorize(
        &self,
        _path: &str,
        _object: &Self::Object,
        _interface: &InterfaceRef,
        _operation: &str,
    ) -> bool { ... }
    fn observe_object(&self, path: &str) -> Result<Object, CallError> { ... }
    fn observe_object_with_context(
        &self,
        context: &ExecutionContext,
        path: &str,
    ) -> Result<Object, CallError> { ... }
    fn fetch_interface(
        &self,
        registry: &InterfaceRegistry,
        reference: &InterfaceReference,
    ) -> Result<InterfaceObservation, ProtocolError> { ... }
    fn call_operation(
        &self,
        request: CallRequest,
    ) -> Result<CallResult, CallError> { ... }
    fn call_operation_with_context(
        &self,
        context: &ExecutionContext,
        request: CallRequest,
    ) -> Result<CallResult, CallError> { ... }
    fn call_operation_with_context_and_decoder<E>(
        &self,
        context: &ExecutionContext,
        target: Target,
        interface: InterfaceTarget,
        operation: String,
        decode_arguments: impl FnOnce(&InterfaceDescriptor) -> Result<BTreeMap<String, Value>, E>,
    ) -> Result<CallResult, CallError> { ... }
}
Expand description

A request-scoped Worldspace resolver and execution boundary.

with_object must resolve the current object at path exactly once and pass a publication that pins its current interface set, implementations, and backend target and all current scope Object associations for the duration of operation. Attach them with PublishedObject::bind_scope inside this same boundary, never via an independent scope prelookup. A new Object at the same path needs a fresh Scope; ordinary state changes retain the handle. Providers own lifetime/atomicity enforcement, including external writers and backend commit/rollback. The execution context is the runtime-neutral carrier for cancellation, deadline, and resource controls. The borrowed publication cannot escape the callback.

Providers that can roll back mutable operations should override ObjectProvider::execute_operation, hold their transaction across the callback, and call OperationAttempt::confirm_rollback only after rollback succeeds. The default boundary conservatively preserves unknown outcomes.

Required Associated Types§

Source

type Object: WipObject

Host-private object type produced by this provider.

Required Methods§

Source

fn with_object<R>( &self, context: &ExecutionContext, path: &str, operation: impl FnOnce(&PublishedObject<Self::Object>) -> R, ) -> ProviderResult<R>

Runs a callback against the single object snapshot resolved at path.

Provided Methods§

Source

fn execute_operation( &self, context: &ExecutionContext, path: &str, operation: impl FnOnce(&PublishedObject<Self::Object>) -> OperationAttempt, ) -> ProviderResult<OperationAttempt>

Runs one operation attempt inside the provider’s atomic backend boundary.

The default implementation delegates to ObjectProvider::with_object and therefore does not add a rollback guarantee. Transactional providers can override this method, inspect the returned OperationAttempt, roll back a failed started attempt, and return its confirmed form.

Source

fn authorize( &self, _path: &str, _object: &Self::Object, _interface: &InterfaceRef, _operation: &str, ) -> bool

Decides whether a declared operation may execute for the current caller.

The hook runs after all validators, membership, operation lookup, and argument validation, but before implementation code. Returning false exposes the operation while producing PermissionDenied.

Source

fn observe_object(&self, path: &str) -> Result<Object, CallError>

Observes the canonical object projection currently published at path.

Source

fn observe_object_with_context( &self, context: &ExecutionContext, path: &str, ) -> Result<Object, CallError>

Observes an object while propagating runtime execution controls.

Source

fn fetch_interface( &self, registry: &InterfaceRegistry, reference: &InterfaceReference, ) -> Result<InterfaceObservation, ProtocolError>

Fetches Descriptor, scope Object ref and Interface validator atomically.

The scope Object may expose no interfaces. Its publication must still bind the live ScopeObservation. Registry retention is not publication.

Source

fn call_operation(&self, request: CallRequest) -> Result<CallResult, CallError>

Resolves and executes a canonical path-targeted operation request.

Structural path validation precedes provider resolution. For a valid request, failure checks follow the exact canonical precedence: path, supplied object validator mismatch, membership, interface validator requirement and mismatch, operation existence, object validator requirement, arguments, then authorization. No failed precondition invokes typed implementation code.

Source

fn call_operation_with_context( &self, context: &ExecutionContext, request: CallRequest, ) -> Result<CallResult, CallError>

Executes an operation while propagating cancellation, deadline, and resource-budget controls to the provider and runtime preflight check.

Source

fn call_operation_with_context_and_decoder<E>( &self, context: &ExecutionContext, target: Target, interface: InterfaceTarget, operation: String, decode_arguments: impl FnOnce(&InterfaceDescriptor) -> Result<BTreeMap<String, Value>, E>, ) -> Result<CallResult, CallError>

Resolves one operation target and decodes its arguments only after all descriptor-independent canonical preconditions have succeeded.

Transport bindings whose value representation depends on the selected interface descriptor should use this method instead of resolving a descriptor before ObjectProvider::call_operation_with_context. The callback executes inside the same exact-once provider boundary after object/interface validators, membership, operation lookup, and required object-validator checks. A callback error becomes InvalidArguments and typed implementation code is not invoked.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§