Commit 5fc809f8 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

zb: return reference to PrimaryHeader



It no longer needs to return a Result of the copy.
Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
parent cef4da03
......@@ -242,7 +242,7 @@ mod tests {
Ok(())
})
.unwrap();
let primary = m.primary_header().unwrap();
let primary = m.primary_header();
assert!(primary.serial_num() == 11);
assert!(primary.flags() == MessageFlags::NoAutoStart);
}
......@@ -554,7 +554,7 @@ mod tests {
loop {
let msg = conn.receive_message().unwrap();
if msg.primary_header().unwrap().serial_num() == serial {
if msg.primary_header().serial_num() == serial {
break;
}
}
......
......@@ -417,7 +417,7 @@ impl Message {
pub(crate) fn bytes_to_completion(&self) -> Result<usize, MessageError> {
let header_len = MIN_MESSAGE_SIZE + self.fields_len()?;
let body_padding = padding_for_8_bytes(header_len);
let body_len = self.primary_header()?.body_len();
let body_len = self.primary_header().body_len();
let required = header_len + body_padding + body_len as usize;
Ok(required - self.bytes.len())
......@@ -441,9 +441,8 @@ impl Message {
}
}
/// Deserialize the primary header.
pub fn primary_header(&self) -> Result<MessagePrimaryHeader, MessageError> {
Ok(self.primary_header.clone())
pub fn primary_header(&self) -> &MessagePrimaryHeader {
&self.primary_header
}
pub(crate) fn modify_primary_header<F>(&mut self, mut modifier: F) -> Result<(), MessageError>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment