Skip to content

Add convenience methods for the number of the Policies and Templates in a PolicySet  #1179

@jv-garcia

Description

@jv-garcia

Category

User level API features/changes

Describe the feature you'd like to request

Hey Cedar team,

My use case involves loading policies from a database and creating a cedar_policy::PolicySet with those. I'd like to introduce some assertions/safety checks so that I can make sure that the number of policies that I have in the policy set equals the amount of policies that I loaded.

To do this I suggest we add cedar_policy::PolicySet::num_of_policies() -> usize (happy to chat about the name, of course), and similar for templates. These methods would be simple proxies for the HashMap::len().

Describe alternatives you've considered

This is possible today using the provided iterators (like here), but doing that requires consuming the iterator. A call to theHashMap's len() would be more efficient.

Additional context

I'm still using 2.4.x, so I need to to backport to that version.

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestThis issue requets a substantial new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions