Skip to content
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

bring the ffi module to 3.2.x #852

Merged
merged 9 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
# Set `RUSTFLAGS` once for all cargo commands so that changing these flags
# doesn't trigger a fresh build.
env:
RUSTFLAGS: '-D warnings -F unsafe-code'
RUSTFLAGS: '-D warnings -F unsafe-code --force-warn deprecated'

steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: ./panic_safety.sh
- run: cargo doc --all-features --no-deps

# All targets are run with the same `RUSTFLAGS
# All targets are run with the same `RUSTFLAGS`
- run: cargo build --verbose
- run: cargo test --verbose
- run: cargo bench --no-run --profile=dev
Expand All @@ -37,7 +37,7 @@ jobs:
cedar_policy_ref: ${{ github.ref }}

# Clippy in its own job so that the `RUSTFLAGS` set for `build_and_test`
# don't effect it. As a side effect, this will run in parallel, saving some
# don't affect it. As a side effect, this will run in parallel, saving some
# time.
clippy:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run_integration_tests_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# Set `RUSTFLAGS` once for all cargo commands so that changing these flags
# doesn't trigger a fresh build.
env:
RUSTFLAGS: '-D warnings -F unsafe-code'
RUSTFLAGS: '-D warnings -F unsafe-code --force-warn deprecated'

steps:
- name: Checkout cedar
Expand Down Expand Up @@ -53,4 +53,3 @@ jobs:
- name: Run corpus tests
working-directory: ./cedar
run: cargo test --verbose --features "integration-testing" -- --ignored

3 changes: 3 additions & 0 deletions cedar-policy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
and `RestrictedExpression::new_decimal` (#661, resolving #659)
- `Entities::into_iter` (#713, resolving #680)
- `Entity::into_inner` (#685, resolving #636)
- New `ffi` module with an improved FFI interface. This will replace the
`frontend` module in the 4.0 release, but is available now for early adopters;
the `frontend` module is now deprecated. (#852)

### Changed

Expand Down
26 changes: 24 additions & 2 deletions cedar-policy/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,9 @@ impl From<authorizer::AuthorizationError> for AuthorizationError {
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Response {
/// Authorization decision
decision: Decision,
pub(crate) decision: Decision,
/// Diagnostics providing more information on how this decision was reached
diagnostics: Diagnostics,
pub(crate) diagnostics: Diagnostics,
}

/// A partially evaluated authorization response.
Expand Down Expand Up @@ -1109,6 +1109,16 @@ impl Diagnostics {
pub fn errors(&self) -> impl Iterator<Item = &AuthorizationError> + '_ {
self.errors.iter()
}

/// Consume the `Diagnostics`, producing owned versions of `reason()` and `errors()`
pub(crate) fn into_components(
self,
) -> (
impl Iterator<Item = PolicyId>,
impl Iterator<Item = AuthorizationError>,
) {
(self.reason.into_iter(), self.errors.into_iter())
}
}

impl Response {
Expand Down Expand Up @@ -1711,6 +1721,18 @@ impl<'a> ValidationResult<'a> {
.map(|w| w as &dyn Diagnostic)
})
}

pub(crate) fn into_errors_and_warnings(
self,
) -> (
impl Iterator<Item = ValidationError<'static>>,
impl Iterator<Item = ValidationWarning<'static>>,
) {
(
self.validation_errors.into_iter(),
self.validation_warnings.into_iter(),
)
}
}

impl<'a> From<cedar_policy_validator::ValidationResult<'a>> for ValidationResult<'static> {
Expand Down
Loading
Loading