Skip to main content

Session

Struct Session 

Source
pub struct Session<S: State, T: Transport + 'static> { /* private fields */ }
Expand description

Type-state session handle.

Session<Unauthenticated> exposes only Session::authenticate. Session<Authenticated> exposes the rest of the protocol surface (Phase 3+ adds invoke, subscribe, etc.).

Implementations§

Source§

impl<T: Transport + 'static> Session<Unauthenticated, T>

Source

pub async fn authenticate( self, creds: Credentials, client: ClientIdentity, caps: Capabilities, ) -> Result<Session<Authenticated, T>, ARCPError>

Drive the four-step handshake (RFC §8.1) and, on success, return a Session<Authenticated>.

On success a background reader task is spawned to dispatch incoming envelopes (job terminal events, etc.) into the session’s pending registry.

§Errors

Returns ARCPError::Unauthenticated if the runtime emits session.rejected or session.unauthenticated, ARCPError::Unavailable if the transport closes mid-handshake, ARCPError::Internal for protocol violations.

Source§

impl<T: Transport + 'static> Session<Authenticated, T>

Source

pub async fn id(&self) -> Result<SessionId, ARCPError>

Return the negotiated session id.

§Errors

Returns ARCPError::Internal if called on a session that somehow reached the Authenticated state without an id (cannot happen in well-formed code).

Source

pub async fn capabilities(&self) -> Capabilities

Return the negotiated capability set.

Source

pub async fn invoke( &self, tool: impl Into<String>, arguments: Value, ) -> Result<JobHandle, ARCPError>

Invoke a tool by name. Returns a JobHandle the caller can await for the terminal result, and which carries the runtime-assigned JobId once job.accepted arrives (RFC §10).

§Errors

Returns ARCPError::Unavailable if the transport closes before the runtime acknowledges the invocation.

Source

pub async fn put_artifact( &self, media_type: impl Into<String>, data: impl Into<String>, retain_seconds: Option<u64>, ) -> Result<ArtifactRef, ARCPError>

Upload an artifact (RFC §16.2). Returns the canonical ArtifactRef the runtime minted.

data must be base64-encoded; the caller is responsible for chunking inputs that exceed the runtime’s inline cap.

§Errors

Returns ARCPError for transport failures, or whatever code the runtime returns in a nack (e.g. ErrorCode::InvalidArgument for malformed base64).

Source

pub async fn fetch_artifact( &self, artifact_id: ArtifactId, ) -> Result<(String, String), ARCPError>

Fetch an artifact by id. Returns (base64_body, media_type).

§Errors

Returns ARCPError::NotFound when the runtime has no such id; ARCPError::Unavailable for transport failures.

Source

pub async fn release_artifact( &self, artifact_id: ArtifactId, ) -> Result<(), ARCPError>

Release (delete) an artifact (RFC §16.2). The runtime does not acknowledge releases; this is fire-and-forget.

§Errors

Returns ARCPError::Unavailable for transport failures.

Source

pub async fn subscribe( &self, filter: SubscriptionFilter, ) -> Result<SubscriptionHandle, ARCPError>

Subscribe to runtime events (RFC §13). Returns a SubscriptionHandle yielding live envelopes that match filter.

§Errors

Returns ARCPError::Unavailable if the transport closes before the runtime acknowledges the subscription.

Trait Implementations§

Source§

impl<S: State, T: Transport + 'static> Debug for Session<S, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, T> Freeze for Session<S, T>

§

impl<S, T> !RefUnwindSafe for Session<S, T>

§

impl<S, T> Send for Session<S, T>
where S: Send,

§

impl<S, T> Sync for Session<S, T>
where S: Sync,

§

impl<S, T> Unpin for Session<S, T>
where S: Unpin,

§

impl<S, T> UnsafeUnpin for Session<S, T>

§

impl<S, T> !UnwindSafe for Session<S, T>

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

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

Source§

fn vzip(self) -> V