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