Skip to content

Commit a6e950c

Browse files
committed
Make ConnectionState sealed.
1 parent fad11e6 commit a6e950c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

iroh/src/endpoint/connection.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,12 @@ pub struct OutgoingZeroRttData {
641641
accepted: Shared<ZeroRttAccepted>,
642642
}
643643

644+
mod sealed {
645+
pub trait Sealed {}
646+
}
647+
644648
/// Trait to track the state of a [`Connection`] at compile time.
645-
pub trait ConnectionState {
649+
pub trait ConnectionState: sealed::Sealed {
646650
/// State-specific data stored in the [`Connection`].
647651
type Data: std::fmt::Debug + Clone;
648652
}
@@ -659,12 +663,15 @@ pub struct IncomingZeroRtt;
659663
#[derive(Debug, Clone)]
660664
pub struct OutgoingZeroRtt;
661665

666+
impl sealed::Sealed for HandshakeCompleted {}
662667
impl ConnectionState for HandshakeCompleted {
663668
type Data = HandshakeCompletedData;
664669
}
670+
impl sealed::Sealed for IncomingZeroRtt {}
665671
impl ConnectionState for IncomingZeroRtt {
666672
type Data = IncomingZeroRttData;
667673
}
674+
impl sealed::Sealed for OutgoingZeroRtt {}
668675
impl ConnectionState for OutgoingZeroRtt {
669676
type Data = OutgoingZeroRttData;
670677
}

0 commit comments

Comments
 (0)