prdoclib/
docfile_wrapper.rs

1//! A wrapper to serialize both content and filename
2
3use crate::doc_filename::DocFileName;
4use serde::Serialize;
5use serde_yaml::Value;
6use std::path::PathBuf;
7
8/// This wrapper is used to extend a docfile with "external" data
9/// such as information we can find in the filename itself, that is:
10/// - pr number
11/// - title
12
13#[derive(Debug, Serialize, Hash, PartialEq, Eq)]
14pub struct DocFileWrapper {
15	/// The file path
16	pub file: PathBuf,
17
18	/// The filename
19	pub doc_filename: DocFileName,
20
21	/// The content of the PRDoc
22	pub content: Option<Value>,
23}
24
25impl DocFileWrapper {
26	/// Create a new wrapper
27	pub fn new(file: PathBuf, filename: DocFileName, content: Option<Value>) -> Self {
28		let file = file.canonicalize().expect("Canonicalize works");
29		Self { file, doc_filename: filename, content }
30	}
31}