pub enum Frame {
Success(String),
Error(String),
Notification {
kind: String,
payload: String,
},
ClientEnv {
event: String,
args: String,
env: BTreeMap<String, String>,
},
PasswordPrompt,
End,
Info(String),
Line(String),
}Expand description
A classified line (or accumulated block) from the OpenVPN management interface.
The frame decoder emits one Frame per logical unit. Most variants
map 1:1 to a wire line; ClientEnv is the
exception — it accumulates the full >CLIENT: header + ENV block
before being emitted.
use bytes::BytesMut;
use tokio_util::codec::Decoder;
use openvpn_mgmt_frame::{Frame, FrameDecoder};
let mut decoder = FrameDecoder::new();
let mut buf = BytesMut::from(
"SUCCESS: pid=42\nERROR: unknown command\nEND\n"
);
assert!(matches!(decoder.decode(&mut buf).unwrap(), Some(Frame::Success(_))));
assert!(matches!(decoder.decode(&mut buf).unwrap(), Some(Frame::Error(_))));
assert!(matches!(decoder.decode(&mut buf).unwrap(), Some(Frame::End)));Variants§
Success(String)
SUCCESS: [text] — a command completed successfully.
Error(String)
ERROR: [text] — a command failed.
Notification
A > notification line (single-line).
kind is the tag before the first : (e.g. "STATE", "LOG").
payload is everything after the :.
>CLIENT: lines with ENV blocks are not emitted as
Notification — they become ClientEnv
instead.
Fields
ClientEnv
A fully accumulated >CLIENT: notification with its ENV block.
All >CLIENT:ENV,key=value lines have been collected; the
terminating >CLIENT:ENV,END has been consumed.
Fields
PasswordPrompt
ENTER PASSWORD: prompt.
End
A bare END line — terminates a multi-line response block.
Info(String)
The first >INFO: line (the connection banner).
Subsequent >INFO: lines are emitted as
Notification with kind = "INFO".
Line(String)
Any line that is not self-describing (no SUCCESS:/ERROR:/>
prefix, not END, not ENTER PASSWORD:).
Higher layers use command-tracking state to decide whether this belongs to a multi-line response or is an unrecognized line.