diff --git a/rups/src/proto/client.rs b/rups/src/proto/client.rs new file mode 100644 index 0000000..0a8ceb1 --- /dev/null +++ b/rups/src/proto/client.rs @@ -0,0 +1,35 @@ +use crate::proto::impl_sentences; + +impl_sentences! { + /// Server responds with the number of prior logins to the given `ups_name` device. + RespondNumLogins ( + { + 0: NumLogins, + 1: Arg, + 2: Arg, + 3: EOL, + }, + { + /// The name of the UPS device. + 1: ups_name, + /// The number of logins to the UPS device. + 2: num_logins, + } + ), +} + +#[cfg(test)] +mod tests { + use super::Sentences; + use crate::proto::test_encode_decode; + #[test] + fn test_encode_decode() { + test_encode_decode!( + ["NUMLOGINS", "nutdev", "42"] <=> + Sentences::RespondNumLogins { + ups_name: "nutdev".into(), + num_logins: "42".into(), + } + ); + } +} diff --git a/rups/src/proto/mod.rs b/rups/src/proto/mod.rs index 846092f..7089071 100644 --- a/rups/src/proto/mod.rs +++ b/rups/src/proto/mod.rs @@ -1,3 +1,8 @@ +/// Client-bound protocol implementation. +/// +/// "Client-bound" implies commands RECEIVED and DECODED by the client. The server implementation +/// must use the same messages to ENCODE and SEND. +pub mod client; /// Server-bound protocol implementation. /// /// "Server-bound" implies commands RECEIVED and DECODED by the server. The client implementation