greentic-component 0.5.2

High-level component loader and store for Greentic components
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::path::Path;

use anyhow::Result;
use bytes::Bytes;
use tokio::fs as tfs;

use crate::path_safety::normalize_under_root;

pub async fn fetch(root: &Path, path: &Path) -> Result<Bytes> {
    let safe = normalize_under_root(root, path)?;
    let data = tfs::read(&safe).await?;
    Ok(Bytes::from(data))
}