pub enum DataLane {
WebRtcDataChannel {
data_channel: Arc<RTCDataChannel>,
rx: Arc<Mutex<Receiver<Bytes>>>,
},
Mpsc {
payload_type: PayloadType,
tx: Sender<RpcEnvelope>,
rx: Arc<Mutex<Receiver<RpcEnvelope>>>,
},
WebSocket {
sink: Arc<Mutex<Option<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>>,
payload_type: PayloadType,
rx: Arc<Mutex<Receiver<Bytes>>>,
},
}Expand description
DataLane - Data transport channel
Each DataLane represents a specific transport path for data/message transmission. MediaTrack uses a separate path via MediaFrameRegistry, not DataLane.
Variants§
WebRtcDataChannel
WebRTC DataChannel Lane
For transmitting messages via WebRTC DataChannel
Fields
data_channel: Arc<RTCDataChannel>Underlying DataChannel
Mpsc
Mpsc Lane
For intra-process communication (Inproc transport)
Note: directly passes RpcEnvelope objects, zero serialization
Fields
payload_type: PayloadTypePayloadType identifier
tx: Sender<RpcEnvelope>Send channel (directly passes RpcEnvelope)
rx: Arc<Mutex<Receiver<RpcEnvelope>>>Receive channel (shared)
WebSocket
WebSocket Lane
For business data transmission in C/S architecture
Fields
sink: Arc<Mutex<Option<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>>Shared Sink (all PayloadTypes share the same WebSocket connection) Uses Option to support lazy initialization
payload_type: PayloadTypePayloadType identifier (used to add message header when sending)
Implementations§
Source§impl DataLane
impl DataLane
Sourcepub async fn send(&self, data: Bytes) -> NetworkResult<()>
pub async fn send(&self, data: Bytes) -> NetworkResult<()>
Sourcepub async fn send_envelope(&self, envelope: RpcEnvelope) -> NetworkResult<()>
pub async fn send_envelope(&self, envelope: RpcEnvelope) -> NetworkResult<()>
Send RpcEnvelope (Inproc only, zero serialization)
§Arguments
envelope: RpcEnvelope object
§Description
This method is only for DataLane::Mpsc, directly passing RpcEnvelope objects,
without serialization/deserialization, achieving zero-copy intra-process communication.
§Example
use actr_protocol::RpcEnvelope;
let envelope = RpcEnvelope { /* ... */ };
data_lane.send_envelope(envelope).await?;Sourcepub async fn recv(&self) -> NetworkResult<Bytes>
pub async fn recv(&self) -> NetworkResult<Bytes>
Sourcepub async fn recv_envelope(&self) -> NetworkResult<RpcEnvelope>
pub async fn recv_envelope(&self) -> NetworkResult<RpcEnvelope>
Source§impl DataLane
DataLane factory methods
impl DataLane
DataLane factory methods
Sourcepub fn mpsc(
payload_type: PayloadType,
tx: Sender<RpcEnvelope>,
rx: Receiver<RpcEnvelope>,
) -> Self
pub fn mpsc( payload_type: PayloadType, tx: Sender<RpcEnvelope>, rx: Receiver<RpcEnvelope>, ) -> Self
Create Mpsc DataLane (accepts plain Receiver)
§Arguments
payload_type: PayloadType identifiertx: send channel (directly passes RpcEnvelope)rx: receive channel (automatically wrapped in Arc<Mutex<>>)
Create Mpsc DataLane (accepts shared Receiver)
§Arguments
payload_type: PayloadType identifiertx: send channel (directly passes RpcEnvelope)rx: shared receive channel
Sourcepub fn webrtc_data_channel(
data_channel: Arc<RTCDataChannel>,
rx: Receiver<Bytes>,
) -> Self
pub fn webrtc_data_channel( data_channel: Arc<RTCDataChannel>, rx: Receiver<Bytes>, ) -> Self
Create WebRTC DataChannel DataLane
§Arguments
data_channel: DataChannel referencerx: receive channel (Bytes zero-copy)
Sourcepub fn websocket(
sink: Arc<Mutex<Option<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>>,
payload_type: PayloadType,
rx: Receiver<Bytes>,
) -> Self
pub fn websocket( sink: Arc<Mutex<Option<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>>, payload_type: PayloadType, rx: Receiver<Bytes>, ) -> Self
Create WebSocket DataLane
§Arguments
sink: shared WebSocket Sink (may not be connected yet, uses Option)payload_type: message type identifierrx: receive channel (Bytes zero-copy)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataLane
impl !RefUnwindSafe for DataLane
impl Send for DataLane
impl Sync for DataLane
impl Unpin for DataLane
impl !UnwindSafe for DataLane
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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