/// Appends the given messages to `self`.
///
/// Returns `Err(InvalidPayload)` if `suffix.messages` is malformed.
/// Returns `Err(InvalidAppend)` and leaves `self` unmodified if
/// `suffix` does not extend `self` gap-free.
Appends the given messages to `self`.
Appends the given messages to ` self ` .
pub(super) fn append(&mut self, suffix: Messages) -> CertifiedSliceResult<()> {
            // Do all validation / fallible operations first, so `self` remains unmodified
            // on error.
            if suffix.begin.get() != self.begin.get() + self.len() as u64 {
                return Err(CertifiedSliceError::InvalidAppend(IndexMismatch));
            }
            let suffix_byte_size = byte_size(&suffix.messages)?;
            // `self.begin` stays unchanged.
            self.messages = FlatMap::from_key_values(
                std::mem::take(&mut self.messages)
                    .into_iter()
                    .chain(suffix.messages.into_iter())
                    .collect(),
            );
            self.count_bytes += suffix_byte_size;
            debug_assert_eq!(byte_size(&self.messages).unwrap(), self.count_bytes);
            Ok(())
        }
pub ( super ) fn append ( & mut self , suffix : Messages ) -> CertifiedSliceResult < ( ) > { // Do all validation / fallible operations first, so `self` remains unmodified // on error. if suffix . begin . get ( ) != self . begin . get ( ) + self . len ( ) as u64 { return Err ( CertifiedSliceError :: InvalidAppend ( IndexMismatch ) ) ; } let suffix_byte_size = byte_size ( & suffix . messages ) ? ; // `self.begin` stays unchanged. self . messages = FlatMap :: from_key_values ( std :: mem :: take ( & mut self . messages ) . into_iter ( ) . chain ( suffix . messages . into_iter ( ) ) . collect ( ) , ) ; self . count_bytes += suffix_byte_size ; debug_assert_eq ! ( byte_size ( self messages ) unwrap ( ) self count_bytes ) ; Ok ( ( ) ) }
Appends the given messages to `self`.
Appends the given messages to ` self ` .
&mut self
suffix
Messages