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>
impl<T: Transport + 'static> Session<Unauthenticated, T>
Sourcepub async fn authenticate(
self,
creds: Credentials,
client: ClientIdentity,
caps: Capabilities,
) -> Result<Session<Authenticated, T>, ARCPError>
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>
impl<T: Transport + 'static> Session<Authenticated, T>
Sourcepub async fn id(&self) -> Result<SessionId, ARCPError>
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).
Sourcepub async fn capabilities(&self) -> Capabilities
pub async fn capabilities(&self) -> Capabilities
Return the negotiated capability set.
Sourcepub async fn invoke(
&self,
tool: impl Into<String>,
arguments: Value,
) -> Result<JobHandle, ARCPError>
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.
Sourcepub async fn put_artifact(
&self,
media_type: impl Into<String>,
data: impl Into<String>,
retain_seconds: Option<u64>,
) -> Result<ArtifactRef, ARCPError>
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).
Sourcepub async fn fetch_artifact(
&self,
artifact_id: ArtifactId,
) -> Result<(String, String), ARCPError>
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.
Sourcepub async fn release_artifact(
&self,
artifact_id: ArtifactId,
) -> Result<(), ARCPError>
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.
Sourcepub async fn subscribe(
&self,
filter: SubscriptionFilter,
) -> Result<SubscriptionHandle, ARCPError>
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.