RuntimeContext

Struct RuntimeContext 

Source
pub struct RuntimeContext { /* private fields */ }
Expand description

RuntimeContext - Runtime’s implementation of Context trait

§设计特性

  • 零虚函数:内部使用 OutGate enum dispatch(非 dyn)
  • 智能路由:根据 Dest 自动选择 InprocOut 或 OutprocOut
  • 完整实现:包含 call/tell 的完整逻辑(编码、发送、解码)
  • 类型安全:泛型方法提供编译时类型检查

§性能

  • OutGate 是 enum,使用静态分发
  • 编译器可完全内联整个调用链
  • 零虚函数调用开销

Implementations§

Source§

impl RuntimeContext

Source

pub fn new( self_id: ActrId, caller_id: Option<ActrId>, request_id: String, inproc_gate: OutGate, outproc_gate: Option<OutGate>, data_stream_registry: Arc<DataStreamRegistry>, media_frame_registry: Arc<MediaFrameRegistry>, signaling_client: Arc<dyn SignalingClient>, credential: AIdCredential, actr_lock: Option<LockFile>, config_dir: Option<PathBuf>, ) -> Self

创建新的 RuntimeContext

§参数
  • self_id: 当前 Actor 的 ID
  • caller_id: 调用方 Actor ID(可选)
  • request_id: 当前请求唯一 ID
  • inproc_gate: 进程内通信 gate(立即可用)
  • outproc_gate: 跨进程通信 gate(可能为 None,等待 WebRTC 初始化)
  • data_stream_registry: DataStream 回调注册表
  • media_frame_registry: MediaTrack 回调注册表
  • signaling_client: 用于路由发现的信令客户端
  • credential: 该 Actor 的凭证(调用信令接口时使用)
  • actr_lock: Actr.lock.toml 依赖配置(用于 fingerprint 查找)
  • config_dir: 配置目录路径(用于 compat.lock.toml Fast Path 缓存)
Source

pub async fn call_raw( &self, target: &Dest, route_key: String, payload_type: PayloadType, payload: Bytes, timeout_ms: i64, ) -> ActorResult<Bytes>

Execute a non-generic RPC request call (useful for language bindings).

Source

pub async fn tell_raw( &self, target: &Dest, route_key: String, payload_type: PayloadType, payload: Bytes, ) -> ActorResult<()>

Execute a non-generic RPC message call (fire-and-forget, useful for language bindings).

Source

pub async fn send_data_stream_with_type( &self, target: &Dest, payload_type: PayloadType, chunk: DataStream, ) -> ActorResult<()>

Send DataStream with an explicit payload type (lane selection).

This is intended for language bindings; the Context trait method send_data_stream() currently defaults to StreamReliable.

Trait Implementations§

Source§

impl Clone for RuntimeContext

Source§

fn clone(&self) -> RuntimeContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Context for RuntimeContext

Source§

fn self_id(&self) -> &ActrId

Get the current Actor’s ID
Source§

fn caller_id(&self) -> Option<&ActrId>

Get the caller’s Actor ID Read more
Source§

fn request_id(&self) -> &str

Get the unique request ID Read more
Source§

fn call<'life0, 'life1, 'async_trait, R>( &'life0 self, target: &'life1 Dest, request: R, ) -> Pin<Box<dyn Future<Output = ActorResult<R::Response>> + Send + 'async_trait>>
where R: 'async_trait + RpcRequest, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a type-safe RPC request and wait for response Read more
Source§

fn tell<'life0, 'life1, 'async_trait, R>( &'life0 self, target: &'life1 Dest, message: R, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where R: 'async_trait + RpcRequest, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a type-safe one-way message (no response expected) Read more
Source§

fn register_stream<'life0, 'async_trait, F>( &'life0 self, stream_id: String, callback: F, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where F: Fn(DataStream, ActrId) -> BoxFuture<'static, ActorResult<()>> + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Register a DataStream callback for a specific stream Read more
Source§

fn unregister_stream<'life0, 'life1, 'async_trait>( &'life0 self, stream_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unregister a DataStream callback Read more
Source§

fn send_data_stream<'life0, 'life1, 'async_trait>( &'life0 self, target: &'life1 Dest, chunk: DataStream, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a DataStream to a destination Read more
Source§

fn discover_route_candidate<'life0, 'life1, 'async_trait>( &'life0 self, target_type: &'life1 ActrType, ) -> Pin<Box<dyn Future<Output = ActorResult<ActrId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Discover a remote Actor of the specified type via the signaling server. Read more
Source§

fn call_raw<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 ActrId, route_key: &'life2 str, payload: Bytes, ) -> Pin<Box<dyn Future<Output = ActorResult<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a raw RPC request (untyped bytes) and wait for response Read more
Source§

fn register_media_track<'life0, 'async_trait, F>( &'life0 self, track_id: String, callback: F, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where F: Fn(MediaSample, ActrId) -> BoxFuture<'static, ActorResult<()>> + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Register a WebRTC native media track callback Read more
Source§

fn unregister_media_track<'life0, 'life1, 'async_trait>( &'life0 self, track_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unregister a media track callback Read more
Source§

fn send_media_sample<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 Dest, track_id: &'life2 str, sample: MediaSample, ) -> Pin<Box<dyn Future<Output = ActorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send media samples via WebRTC native track 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more