1use crate::VmgsClient;
7use crate::non_volatile_store::EncryptionNotSupported;
8use crate::non_volatile_store::VmgsNonVolatileStore;
9use vm_resource::ResolveResource;
10use vm_resource::kind::NonVolatileStoreKind;
11use vmcore::non_volatile_store::resources::ResolvedNonVolatileStore;
12use vmgs_resources::VmgsFileHandle;
13
14pub struct VmgsFileResolver {
16 client: VmgsClient,
17}
18
19impl VmgsFileResolver {
20 pub fn new(client: VmgsClient) -> Self {
22 Self { client }
23 }
24}
25
26impl ResolveResource<NonVolatileStoreKind, VmgsFileHandle> for VmgsFileResolver {
27 type Output = ResolvedNonVolatileStore;
28 type Error = EncryptionNotSupported;
29
30 fn resolve(&self, resource: VmgsFileHandle, (): ()) -> Result<Self::Output, Self::Error> {
31 Ok(VmgsNonVolatileStore::new(
32 self.client.clone(),
33 vmgs_format::FileId(resource.file_id),
34 resource.encrypted,
35 )?
36 .into())
37 }
38}