From fdc05ffb992ac5406ad4113bd14ec905b1cf7ad4 Mon Sep 17 00:00:00 2001 From: Mike English Date: Tue, 29 Aug 2023 00:59:30 -0400 Subject: [PATCH] moq-transport: Make Messages and Objects Clone (#57) --- moq-transport/src/message/announce.rs | 2 +- moq-transport/src/message/announce_error.rs | 2 +- moq-transport/src/message/announce_ok.rs | 2 +- moq-transport/src/message/go_away.rs | 2 +- moq-transport/src/message/mod.rs | 1 + moq-transport/src/message/subscribe.rs | 2 +- moq-transport/src/message/subscribe_error.rs | 2 +- moq-transport/src/message/subscribe_ok.rs | 2 +- moq-transport/src/object/mod.rs | 2 +- 9 files changed, 9 insertions(+), 8 deletions(-) diff --git a/moq-transport/src/message/announce.rs b/moq-transport/src/message/announce.rs index c9491b1..233f536 100644 --- a/moq-transport/src/message/announce.rs +++ b/moq-transport/src/message/announce.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError}; use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct Announce { // The track namespace pub track_namespace: String, diff --git a/moq-transport/src/message/announce_error.rs b/moq-transport/src/message/announce_error.rs index d83350a..800235c 100644 --- a/moq-transport/src/message/announce_error.rs +++ b/moq-transport/src/message/announce_error.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError, VarI use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct AnnounceError { // Echo back the namespace that was announced. // TODO Propose using an ID to save bytes. diff --git a/moq-transport/src/message/announce_ok.rs b/moq-transport/src/message/announce_ok.rs index 4dd20a6..c09d2cc 100644 --- a/moq-transport/src/message/announce_ok.rs +++ b/moq-transport/src/message/announce_ok.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError}; use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct AnnounceOk { // Echo back the namespace that was announced. // TODO Propose using an ID to save bytes. diff --git a/moq-transport/src/message/go_away.rs b/moq-transport/src/message/go_away.rs index 1ebaf53..649c8b5 100644 --- a/moq-transport/src/message/go_away.rs +++ b/moq-transport/src/message/go_away.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError}; use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct GoAway { pub url: String, } diff --git a/moq-transport/src/message/mod.rs b/moq-transport/src/message/mod.rs index 5281d04..b3d8f27 100644 --- a/moq-transport/src/message/mod.rs +++ b/moq-transport/src/message/mod.rs @@ -36,6 +36,7 @@ use webtransport_generic::{RecvStream, SendStream}; // This implements a decode/encode method that uses the specified type. macro_rules! message_types { {$($name:ident = $val:expr,)*} => { + #[derive(Clone)] pub enum Message { $($name($name)),* } diff --git a/moq-transport/src/message/subscribe.rs b/moq-transport/src/message/subscribe.rs index 4688240..3d57cde 100644 --- a/moq-transport/src/message/subscribe.rs +++ b/moq-transport/src/message/subscribe.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError, VarI use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct Subscribe { // An ID we choose so we can map to the track_name. // Proposal: https://github.com/moq-wg/moq-transport/issues/209 diff --git a/moq-transport/src/message/subscribe_error.rs b/moq-transport/src/message/subscribe_error.rs index d1ab9b2..c3a8702 100644 --- a/moq-transport/src/message/subscribe_error.rs +++ b/moq-transport/src/message/subscribe_error.rs @@ -2,7 +2,7 @@ use crate::coding::{decode_string, encode_string, DecodeError, EncodeError, VarI use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SubscribeError { // NOTE: No full track name because of this proposal: https://github.com/moq-wg/moq-transport/issues/209 diff --git a/moq-transport/src/message/subscribe_ok.rs b/moq-transport/src/message/subscribe_ok.rs index bb4d94d..ac88e97 100644 --- a/moq-transport/src/message/subscribe_ok.rs +++ b/moq-transport/src/message/subscribe_ok.rs @@ -2,7 +2,7 @@ use crate::coding::{DecodeError, EncodeError, VarInt}; use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SubscribeOk { // NOTE: No full track name because of this proposal: https://github.com/moq-wg/moq-transport/issues/209 diff --git a/moq-transport/src/object/mod.rs b/moq-transport/src/object/mod.rs index b70bfcd..e017666 100644 --- a/moq-transport/src/object/mod.rs +++ b/moq-transport/src/object/mod.rs @@ -9,7 +9,7 @@ use crate::coding::{DecodeError, EncodeError, VarInt}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use webtransport_generic::{RecvStream, SendStream}; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct Object { // An ID for this track. // Proposal: https://github.com/moq-wg/moq-transport/issues/209