Skip to content

Commit

Permalink
perf: make some u8-sized enums copiable
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <ljedrz@gmail.com>
  • Loading branch information
ljedrz committed May 15, 2020
1 parent 2d7ded5 commit 51afc32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/interledger-stream/src/packet.rs
Expand Up @@ -372,7 +372,7 @@ impl<'a> fmt::Debug for Frame<'a> {
}

/// The Stream Frame types [as defined in the RFC](https://interledger.org/rfcs/0029-stream/#53-frames)
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Copy)]
#[repr(u8)]
pub enum FrameType {
ConnectionClose = 0x01,
Expand Down Expand Up @@ -415,7 +415,7 @@ impl From<u8> for FrameType {
}

/// The STREAM Error Codes [as defined in the RFC](https://interledger.org/rfcs/0029-stream/#54-error-codes)
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Copy)]
#[repr(u8)]
pub enum ErrorCode {
NoError = 0x01,
Expand Down Expand Up @@ -473,7 +473,7 @@ impl<'a> SerializableFrame<'a> for ConnectionCloseFrame<'a> {
}

fn put_contents(&self, buf: &mut impl MutBufOerExt) {
buf.put_u8(self.code.clone() as u8);
buf.put_u8(self.code as u8);
buf.put_var_octet_string(self.message.as_bytes());
}
}
Expand Down Expand Up @@ -641,7 +641,7 @@ impl<'a> SerializableFrame<'a> for StreamCloseFrame<'a> {

fn put_contents(&self, buf: &mut impl MutBufOerExt) {
buf.put_var_uint(self.stream_id);
buf.put_u8(self.code.clone() as u8);
buf.put_u8(self.code as u8);
buf.put_var_octet_string(self.message.as_bytes());
}
}
Expand Down

0 comments on commit 51afc32

Please sign in to comment.