Skip to main content

actions_templates/
readme.rs

1use anyhow::Result;
2use serde::{Deserialize, Serialize};
3use std::{ops::Deref, path::Path};
4
5#[derive(Debug, Serialize, Deserialize, Clone)]
6pub struct ReadME(String);
7
8impl From<String> for ReadME {
9    fn from(value: String) -> Self {
10        Self(value)
11    }
12}
13
14impl ReadME {
15    pub fn from_file<P>(path: P) -> Result<Self>
16    where
17        P: AsRef<Path>,
18    {
19        let file = std::fs::read_to_string(path)?;
20        Ok(Self(file))
21    }
22}
23
24impl Deref for ReadME {
25    type Target = String;
26    fn deref(&self) -> &Self::Target {
27        &self.0
28    }
29}