1#![forbid(unsafe_code)]
14
15use super::ConversationHandler;
16use crate::error::ErrorCode;
17use std::ffi::{CStr, CString};
18
19#[derive(Debug, Clone)]
28#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
29pub struct Conversation {}
30
31impl Conversation {
32 #[must_use]
34 pub const fn new() -> Self {
35 Self {}
36 }
37}
38
39impl Default for Conversation {
40 fn default() -> Self {
41 Self::new()
42 }
43}
44
45impl ConversationHandler for Conversation {
46 fn prompt_echo_on(&mut self, _msg: &CStr) -> Result<CString, ErrorCode> {
47 Err(ErrorCode::CONV_ERR)
48 }
49
50 fn prompt_echo_off(&mut self, _msg: &CStr) -> Result<CString, ErrorCode> {
51 Err(ErrorCode::CONV_ERR)
52 }
53
54 fn text_info(&mut self, _msg: &CStr) {}
55
56 fn error_msg(&mut self, _msg: &CStr) {}
57}
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn test() {
65 let text = CString::new("test").unwrap();
66 let mut c = Conversation::default();
67 assert_eq!(format!("{:?}", c), format!("{:?}", c.clone()));
68
69 assert!(c.prompt_echo_on(&text).is_err());
70 assert!(c.prompt_echo_off(&text).is_err());
71 assert!(c.radio_prompt(&text).is_err());
72 assert!(c.binary_prompt(0, &[]).is_err());
73 c.text_info(&text);
74 c.error_msg(&text);
75 }
76}