use std::path::Path;
use super::{config_cnode::CNode, config_loader::ConfigLoaderSource};
pub struct ConfigVirtualFileSystem
{
cnode: CNode,
}
impl ConfigLoaderSource for ConfigVirtualFileSystem
{
fn is_local(&self) -> bool
{
return false;
}
fn read_file(&self, path: &Path, _dynenv_name: &str) -> Result<String, String>
{
return self.cnode.open(path);
}
fn read_raw_file(&self, path: &Path) -> Result<String, String>
{
return self.cnode.open(path);
}
fn get_serializator(&self, serial_name: &str) -> Result<std::rc::Rc<crate::DynEnvironment>, String>
{
return Err(format!("can not get serializator: '{}', ConfigVirtualFileSystem does not have this info", serial_name));
}
}
impl ConfigVirtualFileSystem
{
pub
fn new<'t>(serialized: &String) -> Result<Self, String>
{
let cnode =
CNode::deserialize_from_string(serialized)?;
return Ok(
Self
{
cnode: cnode
}
);
}
}