From a06d273e690670096b1bf173010f15305bb41e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michel?= Date: Sat, 15 Jul 2023 11:46:19 +0000 Subject: [PATCH] simplyfy the generics usage in warp relay --- moq-warp/src/relay/contribute.rs | 9 +++------ moq-warp/src/relay/distribute.rs | 9 ++------- moq-warp/src/relay/session.rs | 18 ++++++------------ 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/moq-warp/src/relay/contribute.rs b/moq-warp/src/relay/contribute.rs index ae76a1e..ed84f2d 100644 --- a/moq-warp/src/relay/contribute.rs +++ b/moq-warp/src/relay/contribute.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::marker::PhantomData; use std::sync::{Arc, Mutex}; use std::time; @@ -18,7 +17,7 @@ use crate::model::{broadcast, segment, track}; use crate::source::Source; // TODO experiment with making this Clone, so every task can have its own copy. -pub struct Session { +pub struct Session { // Used to receive objects. objects: RecvObjects, @@ -36,10 +35,9 @@ pub struct Session { // Tasks we are currently serving. run_segments: JoinSet>, // receiving objects - _marker: PhantomData, } -impl + Send> Session { +impl + Send> Session { pub fn new( objects: RecvObjects, control: control::Component, @@ -52,7 +50,6 @@ impl + Send> Sessi broadcasts: HashMap::new(), publishers: Publishers::new(), run_segments: JoinSet::new(), - _marker: PhantomData, } } @@ -180,7 +177,7 @@ impl + Send> Sessi } } -impl Drop for Session { +impl Drop for Session { fn drop(&mut self) { // Unannounce all broadcasts we have announced. // TODO make this automatic so we can't screw up? diff --git a/moq-warp/src/relay/distribute.rs b/moq-warp/src/relay/distribute.rs index e70230c..91ab35b 100644 --- a/moq-warp/src/relay/distribute.rs +++ b/moq-warp/src/relay/distribute.rs @@ -1,5 +1,3 @@ -use std::marker::PhantomData; - use anyhow::Context; use bytes::Buf; @@ -11,7 +9,7 @@ use moq_transport::{Announce, AnnounceError, AnnounceOk, Object, Subscribe, Subs use super::{broker, control}; use crate::model::{segment, track}; -pub struct Session { +pub struct Session { // Objects are sent to the client objects: SendObjects, @@ -23,11 +21,9 @@ pub struct Session { // A list of tasks that are currently running. run_subscribes: JoinSet, // run subscriptions, sending the returned error if they fail - - _marker: PhantomData, } -impl Session where +impl Session where S: SendStream + Send, C: Connection + Send + 'static { pub fn new( @@ -40,7 +36,6 @@ impl Session where control, broker, run_subscribes: JoinSet::new(), - _marker: PhantomData, } } diff --git a/moq-warp/src/relay/session.rs b/moq-warp/src/relay/session.rs index 46007b4..752a080 100644 --- a/moq-warp/src/relay/session.rs +++ b/moq-warp/src/relay/session.rs @@ -1,22 +1,18 @@ -use std::marker::PhantomData; - use webtransport_generic::{SendStream, Connection, RecvStream}; use super::{broker, contribute, control, distribute}; -pub struct Session { +pub struct Session { // Split logic into contribution/distribution to reduce the problem space. - contribute: contribute::Session, - distribute: distribute::Session, + contribute: contribute::Session, + distribute: distribute::Session, // Used to receive control messages and forward to contribute/distribute. - control: control::Main, - _marker: PhantomData, - _marker_r: PhantomData, + control: control::Main, } -impl Session where +impl Session where R: RecvStream + Send + 'static, S: SendStream + Send, C: Connection + Send + 'static @@ -24,7 +20,7 @@ impl Session where pub async fn from_transport_session( session: moq_transport::Session, broker: broker::Broadcasts, - ) -> anyhow::Result> { + ) -> anyhow::Result> { let (control, objects) = session.split(); let (objects_send, objects_recv) = objects.split(); @@ -37,8 +33,6 @@ impl Session where control, contribute, distribute, - _marker: PhantomData, - _marker_r: PhantomData, }; Ok(session)