use livekit_common::RemoteParticipantRegistry;
use livekit_data_stream::api::{StreamResult, StreamTextOptions, TextStreamInfo};
use livekit_protocol as proto;
use std::future::Future;
#[derive(Debug, Clone, thiserror::Error)]
#[error("{0}")]
pub struct RpcTransportError(String);
impl RpcTransportError {
pub fn new(source: impl std::fmt::Display) -> Self {
Self(source.to_string())
}
}
pub trait RpcTransport: RemoteParticipantRegistry {
fn publish_data(
&self,
data: proto::DataPacket,
) -> impl Future<Output = Result<(), RpcTransportError>> + Send;
fn send_text(
&self,
text: &str,
options: StreamTextOptions,
) -> impl Future<Output = StreamResult<TextStreamInfo>> + Send;
fn server_version(&self) -> Option<String>;
}