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
use std::{ffi::OsString, path::PathBuf};
use crate::{LibSourceSpec, boot_codec_name, codec_lib_symbol};
/// Parsed bootloader controls and payload data.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct CliBoot {
/// Codec name selected with `--codec`, or `None` for the default.
pub codec: Option<String>,
/// Library sources to load, in `--load` order.
pub loads: Vec<LibSourceSpec>,
/// Optional native audio provider source requested by the operator.
pub native_audio_provider: Option<Box<LibSourceSpec>>,
/// Whether `--list` requested a loaded-lib listing.
pub list: bool,
/// Symbol passed to `--inspect`, if any.
pub inspect: Option<String>,
/// Payload data preserved for the loaded-lib handoff.
pub payload: Payload,
}
impl CliBoot {
/// Builds the data envelope handed to loaded libraries.
pub fn envelope(&self) -> CliEnvelope {
let codec_name = boot_codec_name(self);
CliEnvelope {
codec: codec_lib_symbol(codec_name),
verb: self
.payload
.args
.first()
.map(|arg| arg.to_string_lossy().into_owned()),
args: self.payload.args.clone(),
eval: self.payload.eval.clone(),
script: self.payload.script.clone(),
stdin: self.payload.stdin.clone(),
}
}
}
/// Payload preserved for loaded-lib behavior.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Payload {
/// Trailing positional arguments handed to the loaded entrypoint.
pub args: Vec<OsString>,
/// Eval text carried from `--eval`.
pub eval: Option<String>,
/// Script path carried from `--script`.
pub script: Option<PathBuf>,
/// Stdin text carried from `--stdin`.
pub stdin: Option<String>,
}
/// Data envelope supplied to the selected loaded-lib entrypoint.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CliEnvelope {
/// Codec library symbol selected for the boot session.
pub codec: String,
/// First payload argument, exposed as the loaded-lib verb.
pub verb: Option<String>,
/// Full payload argument list.
pub args: Vec<OsString>,
/// Eval text carried from `--eval`.
pub eval: Option<String>,
/// Script path carried from `--script`.
pub script: Option<PathBuf>,
/// Stdin text carried from `--stdin`.
pub stdin: Option<String>,
}