我使用一个名为RtspClient的特性,以便使用不同的rtsp客户端创建不同的Stream对象:
pub trait RtspClient {
fn url(&self) -> Option<String>;
fn username(&self) -> Option<String>;
fn password(&self) -> Option<String>;
fn connect(&self) -> Result<(), RtspClientError>;
fn disconnect(&self) -> Result<(), RtspClientError>;
fn set_on_produce<F: Fn(EncodedPacket)>(&self, f: F);
}然后我就这样用它:
struct Stream {
pub rtsp_client: Arc<Mutex<dyn RtspClient>>,
}但我得到的错误是,RtspClient不能用作对象,因为set_on_produce具有泛型类型。
如何为rtsp_client使用动态调度,并且仍然能够使用set_on_produce设置闭包回调
https://stackoverflow.com/questions/64019215
复制相似问题