mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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:
committed by
GitHub
parent
ee898e112e
commit
46e28b36f8
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user