Skip to content

Commit f920a26

Browse files
authored
bring the ffi module to 3.2.x (#852)
Signed-off-by: Craig Disselkoen <[email protected]>
1 parent 2b63a83 commit f920a26

File tree

15 files changed

+2928
-13
lines changed

15 files changed

+2928
-13
lines changed

.github/workflows/build_and_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ jobs:
1414
# Set `RUSTFLAGS` once for all cargo commands so that changing these flags
1515
# doesn't trigger a fresh build.
1616
env:
17-
RUSTFLAGS: '-D warnings -F unsafe-code'
17+
RUSTFLAGS: '-D warnings -F unsafe-code --force-warn deprecated'
1818

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

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

3939
# Clippy in its own job so that the `RUSTFLAGS` set for `build_and_test`
40-
# don't effect it. As a side effect, this will run in parallel, saving some
40+
# don't affect it. As a side effect, this will run in parallel, saving some
4141
# time.
4242
clippy:
4343
runs-on: ubuntu-latest

.github/workflows/run_integration_tests_reusable.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
# Set `RUSTFLAGS` once for all cargo commands so that changing these flags
2525
# doesn't trigger a fresh build.
2626
env:
27-
RUSTFLAGS: '-D warnings -F unsafe-code'
27+
RUSTFLAGS: '-D warnings -F unsafe-code --force-warn deprecated'
2828

2929
steps:
3030
- name: Checkout cedar
@@ -53,4 +53,3 @@ jobs:
5353
- name: Run corpus tests
5454
working-directory: ./cedar
5555
run: cargo test --verbose --features "integration-testing" -- --ignored
56-

cedar-policy/CHANGELOG.md

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

1720
### Changed
1821

cedar-policy/src/api.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,9 @@ impl From<authorizer::AuthorizationError> for AuthorizationError {
844844
#[derive(Debug, PartialEq, Eq, Clone)]
845845
pub struct Response {
846846
/// Authorization decision
847-
decision: Decision,
847+
pub(crate) decision: Decision,
848848
/// Diagnostics providing more information on how this decision was reached
849-
diagnostics: Diagnostics,
849+
pub(crate) diagnostics: Diagnostics,
850850
}
851851

852852
/// A partially evaluated authorization response.
@@ -1109,6 +1109,16 @@ impl Diagnostics {
11091109
pub fn errors(&self) -> impl Iterator<Item = &AuthorizationError> + '_ {
11101110
self.errors.iter()
11111111
}
1112+
1113+
/// Consume the `Diagnostics`, producing owned versions of `reason()` and `errors()`
1114+
pub(crate) fn into_components(
1115+
self,
1116+
) -> (
1117+
impl Iterator<Item = PolicyId>,
1118+
impl Iterator<Item = AuthorizationError>,
1119+
) {
1120+
(self.reason.into_iter(), self.errors.into_iter())
1121+
}
11121122
}
11131123

11141124
impl Response {
@@ -1711,6 +1721,18 @@ impl<'a> ValidationResult<'a> {
17111721
.map(|w| w as &dyn Diagnostic)
17121722
})
17131723
}
1724+
1725+
pub(crate) fn into_errors_and_warnings(
1726+
self,
1727+
) -> (
1728+
impl Iterator<Item = ValidationError<'static>>,
1729+
impl Iterator<Item = ValidationWarning<'static>>,
1730+
) {
1731+
(
1732+
self.validation_errors.into_iter(),
1733+
self.validation_warnings.into_iter(),
1734+
)
1735+
}
17141736
}
17151737

17161738
impl<'a> From<cedar_policy_validator::ValidationResult<'a>> for ValidationResult<'static> {

0 commit comments

Comments
 (0)