comparison src/pam_ffi/handle.rs @ 74:c7c596e6388f

Make conversations type-safe (last big reorg) (REAL) (NOT CLICKBAIT) In previous versions of Conversation, you could send messages and then return messages of the wrong type or in the wrong order or whatever. The receiver would then have to make sure that there were the right number of messages and that each message was the right type. That's annoying. This change makes the `Message` enum a two-way channel, where the asker puts their question into it, and then the answerer (the conversation) puts the answer in and returns control to the asker. The asker then only has to pull the Answer of the type they wanted out of the message.
author Paul Fisher <paul@pfish.zone>
date Fri, 06 Jun 2025 22:21:17 -0400
parents ac6881304c78
children
comparison
equal deleted inserted replaced
73:ac6881304c78 74:c7c596e6388f
142 cstr_item!(set = set_authtok_item, item = ItemType::AuthTok); 142 cstr_item!(set = set_authtok_item, item = ItemType::AuthTok);
143 cstr_item!(set = set_old_authtok_item, item = ItemType::OldAuthTok); 143 cstr_item!(set = set_old_authtok_item, item = ItemType::OldAuthTok);
144 } 144 }
145 145
146 impl Conversation for LibPamHandle { 146 impl Conversation for LibPamHandle {
147 fn converse(&mut self, messages: &[Message]) -> Result<Vec<Response>> { 147 fn communicate(&mut self, messages: &[Message]) -> Result<Vec<Response>> {
148 self.conversation_item()?.converse(messages) 148 self.conversation_item()?.communicate(messages)
149 } 149 }
150 } 150 }
151 151
152 impl PamModuleOnly for LibPamHandle { 152 impl PamModuleOnly for LibPamHandle {
153 fn get_authtok(&mut self, prompt: Option<&str>) -> Result<&str> { 153 fn get_authtok(&mut self, prompt: Option<&str>) -> Result<&str> {