DataLane

Enum DataLane 

Source
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

§rx: Arc<Mutex<Receiver<Bytes>>>

Receive channel (shared, uses Bytes for zero-copy)

§

Mpsc

Mpsc Lane

For intra-process communication (Inproc transport)

Note: directly passes RpcEnvelope objects, zero serialization

Fields

§payload_type: PayloadType

PayloadType 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: PayloadType

PayloadType identifier (used to add message header when sending)

§rx: Arc<Mutex<Receiver<Bytes>>>

Receive channel (independent, routed by dispatcher, uses Bytes for zero-copy)

Implementations§

Source§

impl DataLane

Source

pub async fn send(&self, data: Bytes) -> NetworkResult<()>

Send message

§Arguments
  • data: message data (uses Bytes for zero-copy)
§Example
use bytes::Bytes;
data_lane.send(Bytes::from_static(b"hello")).await?;
Source

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?;
Source

pub async fn recv(&self) -> NetworkResult<Bytes>

Receive message

Blocks until a message is received or the channel is closed.

§Returns
  • Ok(Bytes): received message data (zero-copy)
  • Err: channel closed or other error
§Example
let data = data_lane.recv().await?;
println!("Received {} bytes", data.len());
Source

pub async fn recv_envelope(&self) -> NetworkResult<RpcEnvelope>

Receive RpcEnvelope (Inproc only)

§Returns
  • Ok(RpcEnvelope): received message object
  • Err: channel closed
§Description

This method is only for DataLane::Mpsc, directly receiving RpcEnvelope objects, zero-copy.

Source

pub async fn try_recv(&self) -> NetworkResult<Option<Bytes>>

Try to receive message (non-blocking)

§Returns
  • Ok(Some(data)): received message (zero-copy)
  • Ok(None): no message available
  • Err: channel closed or other error
Source

pub fn lane_type(&self) -> &'static str

Get DataLane type name (for logging)

Source§

impl DataLane

DataLane factory methods

Source

pub fn mpsc( payload_type: PayloadType, tx: Sender<RpcEnvelope>, rx: Receiver<RpcEnvelope>, ) -> Self

Create Mpsc DataLane (accepts plain Receiver)

§Arguments
  • payload_type: PayloadType identifier
  • tx: send channel (directly passes RpcEnvelope)
  • rx: receive channel (automatically wrapped in Arc<Mutex<>>)
Source

pub fn mpsc_shared( payload_type: PayloadType, tx: Sender<RpcEnvelope>, rx: Arc<Mutex<Receiver<RpcEnvelope>>>, ) -> Self

Create Mpsc DataLane (accepts shared Receiver)

§Arguments
  • payload_type: PayloadType identifier
  • tx: send channel (directly passes RpcEnvelope)
  • rx: shared receive channel
Source

pub fn webrtc_data_channel( data_channel: Arc<RTCDataChannel>, rx: Receiver<Bytes>, ) -> Self

Create WebRTC DataChannel DataLane

§Arguments
  • data_channel: DataChannel reference
  • rx: receive channel (Bytes zero-copy)
Source

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 identifier
  • rx: receive channel (Bytes zero-copy)

Trait Implementations§

Source§

impl Clone for DataLane

Source§

fn clone(&self) -> DataLane

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 Debug for DataLane

Source§

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

Formats the value using the given formatter. 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