-
Notifications
You must be signed in to change notification settings - Fork 107
Unify the signature of PolicySet::annotation
and PolicySet::template_annotation
#1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify the signature of PolicySet::annotation
and PolicySet::template_annotation
#1131
Conversation
…te_annotation` Signed-off-by: Shaobo He <[email protected]>
Signed-off-by: Shaobo He <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll leave it to a Rust expert to comment on whether get_template_ref
is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I don't see a problem with the proposed Core interface
/// Lookup a template by policy id | ||
/// Lookup a template by policy id, returns [`Option<Arc<Template>>`] | ||
pub fn get_template(&self, id: &PolicyID) -> Option<Arc<Template>> { | ||
self.templates.get(id).cloned() | ||
} | ||
|
||
/// Lookup a template by policy id, returns [`Option<&Template>`] | ||
pub fn get_template_ref(&self, id: &PolicyID) -> Option<&Template> { | ||
self.templates.get(id).map(AsRef::as_ref) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in other places we call these get_template_arc
and just get_template
. Should we change the other places to match this convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think get_template_arc
and get_template
make more sense to me.
Signed-off-by: Shaobo He <[email protected]>
Signed-off-by: Shaobo He <[email protected]>
Description of changes
This PR change the return type to both methods to
Option<&str>
. Due to the author's limited knowledge of Rust, I have to add a new function in core to get a reference to theTemplate
. Otherwise we could let the return type beOption<SmolStr>
.Issue #, if available
#1116
Checklist for requesting a review
The change in this PR is (choose one, and delete the other options):
cedar-policy
(e.g., changes to the signature of an existing API).I confirm that this PR (choose one, and delete the other options):
I confirm that
cedar-spec
(choose one, and delete the other options):