From 713b756499f380283a275298f47b4b0044cf9462 Mon Sep 17 00:00:00 2001 From: John Millikin Date: Thu, 26 Oct 2023 10:44:39 +0900 Subject: [PATCH] Update `ControlMessages*` based on implementation PR --- text/3430-unix-socket-ancillary-data-v2.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/text/3430-unix-socket-ancillary-data-v2.md b/text/3430-unix-socket-ancillary-data-v2.md index 22ae1a02e71..49968d7e9b9 100644 --- a/text/3430-unix-socket-ancillary-data-v2.md +++ b/text/3430-unix-socket-ancillary-data-v2.md @@ -166,12 +166,12 @@ inspected and iterated over to obtain `ControlMessage` values. ```rust -struct ControlMessages; +struct ControlMessages { ... }; impl ControlMessages { + fn from_bytes(bytes: &[u8]) -> &ControlMessages; fn as_bytes(&self) -> &[u8]; fn is_empty(&self) -> bool; - fn len(&self) -> usize; fn iter(&self) -> ControlMessagesIter<'_>; } @@ -185,6 +185,11 @@ struct ControlMessagesIter<'a> { ... } impl<'a> Iterator for ControlMessagesIter<'a> { type Item = ControlMessage<'a>; } + +impl ControlMessagesIter<'a> { + // For inspecting non-iterable fragment in truncated buffer. + fn into_bytes(self) -> &'a [u8]; +} ``` A `ControlMessagesBuf` is the owned variant of `ControlMessages`. It exposes a @@ -201,8 +206,7 @@ impl ControlMessagesBuf { fn capacity(&self) -> usize; - fn push(&mut self, message: &ControlMessage<'_>); - fn extend_from_slice(&mut self, messages: &[ControlMessage<'_>]); + fn push(&mut self, message: impl Into>); fn reserve(&mut self, additional: usize); @@ -220,7 +224,6 @@ impl ControlMessagesBuf { } impl AsRef for ControlMessagesBuf; -impl AsMut for ControlMessagesBuf; impl Deref for ControlMessagesBuf { type Target = ControlMessages; @@ -233,6 +236,7 @@ impl<'a> IntoIterator for &'a ControlMessagesBuf { } impl Extend> for ControlMessagesBuf; +impl Extend<&ControlMessage<'_>> for ControlMessagesBuf; ``` ## Ancillary data