feat: get_policies: Way to obtain policy files and content (#267)

closes #254

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-06-19 03:01:55 -04:00
committed by GitHub
parent ee898e112e
commit 46e28b36f8
12 changed files with 194 additions and 5 deletions
+13
View File
@@ -20,6 +20,7 @@ struct SourceInternal {
pub lines: Vec<(u32, u32)>,
}
/// A policy file.
#[derive(Clone)]
#[cfg_attr(feature = "ast", derive(serde::Serialize))]
pub struct Source {
@@ -27,6 +28,18 @@ pub struct Source {
src: Rc<SourceInternal>,
}
impl Source {
/// The path associated with the policy file.
pub fn get_path(&self) -> &String {
&self.src.file
}
/// The contents of the policy file.
pub fn get_contents(&self) -> &String {
&self.src.contents
}
}
impl cmp::Ord for Source {
fn cmp(&self, other: &Source) -> cmp::Ordering {
Rc::as_ptr(&self.src).cmp(&Rc::as_ptr(&other.src))