1#![forbid(unsafe_code)]
7
8mod broker;
9mod client;
10pub mod non_volatile_store;
11pub mod resolver;
12
13pub use broker::VmgsBrokerError;
14pub use client::VmgsClient;
15pub use client::VmgsClientError;
16
17use crate::broker::VmgsBrokerTask;
18use pal_async::task::Spawn;
19use pal_async::task::Task;
20
21pub fn spawn_vmgs_broker(spawner: impl Spawn, vmgs: vmgs::Vmgs) -> (VmgsClient, Task<()>) {
24 let (control_send, control_recv) = mesh::mpsc_channel();
25
26 let process_loop_handle = spawner.spawn("vmgs-broker", async move {
27 VmgsBrokerTask::new(vmgs).run(control_recv).await
28 });
29
30 (
31 VmgsClient {
32 control: control_send,
33 },
34 process_loop_handle,
35 )
36}
37
38#[derive(inspect::Inspect)]
45#[inspect(transparent)]
46pub struct VmgsThinClient(VmgsClient);
47
48impl VmgsThinClient {
49 pub fn new(vmgs_client: VmgsClient) -> Self {
51 Self(vmgs_client)
52 }
53
54 pub async fn save(&self) -> Result<vmgs::save_restore::state::SavedVmgsState, VmgsClientError> {
56 self.0.save().await
57 }
58}