Skip to content

Commit 7a636d3

Browse files
committed
remove unnecessary mutable borrows in API
Thanks, @aep. Fixes #32
1 parent 3ed331a commit 7a636d3

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "A pure-rust implementation of the Noise Protocol Framework"
44
homepage = "https://snow.rs"
55
documentation = "https://snow.rs/doc/snow"
66
repository = "https://github.com/mcginty/snow"
7-
version = "0.4.0-alpha1"
7+
version = "0.4.0-alpha2"
88
authors = ["Jake McGinty <[email protected]>", "trevp"]
99
license = "Unlicense"
1010
categories = ["cryptography"]

src/session.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ impl Session {
109109
///
110110
/// Will result in `SnowError::StateProblem` if not in stateless transport mode.
111111
#[must_use]
112-
pub fn write_message_with_nonce(&mut self, nonce: u64, payload: &[u8], output: &mut [u8]) -> Result<usize, SnowError> {
112+
pub fn write_message_with_nonce(&self, nonce: u64, payload: &[u8], output: &mut [u8]) -> Result<usize, SnowError> {
113113
match *self {
114-
Session::StatelessTransport(ref mut state) => state.write_transport_message(nonce, payload, output),
115-
_ => bail!(StateProblem::StatelessTransportMode),
114+
Session::StatelessTransport(ref state) => state.write_transport_message(nonce, payload, output),
115+
_ => bail!(StateProblem::StatelessTransportMode),
116116
}
117117
}
118118

@@ -149,10 +149,10 @@ impl Session {
149149
///
150150
/// Will result in `SnowError::StateProblem` if not in stateless transport mode.
151151
#[must_use]
152-
pub fn read_message_with_nonce(&mut self, nonce: u64, input: &[u8], payload: &mut [u8]) -> Result<usize, SnowError> {
152+
pub fn read_message_with_nonce(&self, nonce: u64, input: &[u8], payload: &mut [u8]) -> Result<usize, SnowError> {
153153
match *self {
154-
Session::StatelessTransport(ref mut state) => state.read_transport_message(nonce, input, payload),
155-
_ => bail!(StateProblem::StatelessTransportMode),
154+
Session::StatelessTransport(ref state) => state.read_transport_message(nonce, input, payload),
155+
_ => bail!(StateProblem::StatelessTransportMode),
156156
}
157157
}
158158

@@ -339,4 +339,4 @@ impl TryFrom<HandshakeState> for StatelessTransportState {
339339
fn try_from(old: HandshakeState) -> Result<Self, Self::Error> {
340340
StatelessTransportState::new(old)
341341
}
342-
}
342+
}

src/stateless_transportstate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl StatelessTransportState {
4242
self.rs.as_option_ref().map(|rs| &rs[..self.dh_len])
4343
}
4444

45-
pub fn write_transport_message(&mut self,
45+
pub fn write_transport_message(&self,
4646
nonce: u64,
4747
payload: &[u8],
4848
message: &mut [u8]) -> Result<usize, SnowError> {
@@ -52,7 +52,7 @@ impl StatelessTransportState {
5252
bail!(SnowError::Input);
5353
}
5454

55-
let cipher = if self.initiator { &mut self.cipherstates.0 } else { &mut self.cipherstates.1 };
55+
let cipher = if self.initiator { &self.cipherstates.0 } else { &self.cipherstates.1 };
5656
Ok(cipher.encrypt(nonce, payload, message))
5757
}
5858

0 commit comments

Comments
 (0)