toe_beans/v4/message/options/
overload_options.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
5#[repr(u8)]
6pub enum OverloadOptions {
7 File,
9 Sname,
11 Both,
13}
14
15impl From<&OverloadOptions> for u8 {
16 fn from(mtype: &OverloadOptions) -> Self {
17 match mtype {
18 OverloadOptions::File => 1,
19 OverloadOptions::Sname => 2,
20 OverloadOptions::Both => 3,
21 }
22 }
23}
24
25impl From<&[u8]> for OverloadOptions {
26 fn from(value: &[u8]) -> Self {
27 match value[0] {
28 1 => OverloadOptions::File,
29 2 => OverloadOptions::Sname,
30 3 => OverloadOptions::Both,
31 _ => OverloadOptions::Both,
32 }
33 }
34}
35
36impl OverloadOptions {
37 #[inline]
39 pub fn extend_into(&self, bytes: &mut Vec<u8>, tag: u8) {
40 bytes.push(tag); bytes.push(1); bytes.push(self.into()); }
44}