Mercurial > crates > nonstick
comparison src/libpam/handle.rs @ 96:f3e260f9ddcb
Make conversation trait use immutable references.
Since sending a conversation a message doesn't really "mutate" it,
it shouldn't really be considered "mutable" for that purpose.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 23 Jun 2025 14:26:34 -0400 |
parents | 51c9d7e8261a |
children | efe2f5f8b5b2 |
comparison
equal
deleted
inserted
replaced
95:51c9d7e8261a | 96:f3e260f9ddcb |
---|---|
125 cstr_item!(set = set_authtok_item, item = ItemType::AuthTok); | 125 cstr_item!(set = set_authtok_item, item = ItemType::AuthTok); |
126 cstr_item!(set = set_old_authtok_item, item = ItemType::OldAuthTok); | 126 cstr_item!(set = set_old_authtok_item, item = ItemType::OldAuthTok); |
127 } | 127 } |
128 | 128 |
129 impl Conversation for LibPamHandle { | 129 impl Conversation for LibPamHandle { |
130 fn communicate(&mut self, messages: &[Message]) { | 130 fn communicate(&self, messages: &[Message]) { |
131 match self.conversation_item() { | 131 match self.conversation_item() { |
132 Ok(conv) => conv.communicate(messages), | 132 Ok(conv) => conv.communicate(messages), |
133 Err(e) => { | 133 Err(e) => { |
134 for msg in messages { | 134 for msg in messages { |
135 msg.set_error(e) | 135 msg.set_error(e) |
202 }; | 202 }; |
203 ErrorCode::result_from(ret) | 203 ErrorCode::result_from(ret) |
204 } | 204 } |
205 | 205 |
206 /// Gets the `PAM_CONV` item from the handle. | 206 /// Gets the `PAM_CONV` item from the handle. |
207 fn conversation_item(&mut self) -> Result<&mut LibPamConversation<'_>> { | 207 fn conversation_item(&self) -> Result<&mut LibPamConversation<'_>> { |
208 let output: *mut LibPamConversation = ptr::null_mut(); | 208 let output: *mut LibPamConversation = ptr::null_mut(); |
209 let result = unsafe { | 209 let result = unsafe { |
210 pam_ffi::pam_get_item( | 210 pam_ffi::pam_get_item( |
211 self, | 211 self, |
212 ItemType::Conversation.into(), | 212 ItemType::Conversation.into(), |