Skip to content

Commit

Permalink
wip: datalog foreign function interface prototype
Browse files Browse the repository at this point in the history
This allows using external functions in datalog.

This makes it easy to provide custom logic without extending the spec for every use-case, at the expense of portability: behaviour is no longer guaranteed to be consistent cross languages, and some languages won’t be able to support it at all (for instance JS as of now).

Todo:
- stricter conversions from datalog
- feature-gating if possible

Open questions:
- enum index for the FFI variants (contiguous or not?)
- how to provide functions (right now, function pointers: prevent mutability and closing over arguments)
- how to provide arguments (right now, datalog::Term, so symbols have to be resolved, and functions returning strings have to register new symbols)
  • Loading branch information
divarvel committed Oct 2, 2024
1 parent 22bd667 commit 4f68cf3
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 64 deletions.
2 changes: 2 additions & 0 deletions biscuit-auth/src/capi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum ErrorKind {
FormatPublicKeyTableOverlap,
FormatUnknownExternalKey,
FormatUnknownSymbol,
FormatMissingFfiName,
AppendOnSealed,
LogicInvalidBlockRule,
LogicUnauthorized,
Expand Down Expand Up @@ -158,6 +159,7 @@ pub extern "C" fn error_kind() -> ErrorKind {
ErrorKind::FormatUnknownExternalKey
}
Token::Format(Format::UnknownSymbol(_)) => ErrorKind::FormatUnknownSymbol,
Token::Format(Format::MissingFfiName) => ErrorKind::FormatMissingFfiName,
Token::AppendOnSealed => ErrorKind::AppendOnSealed,
Token::AlreadySealed => ErrorKind::AlreadySealed,
Token::Language(_) => ErrorKind::LanguageError,
Expand Down
Loading

0 comments on commit 4f68cf3

Please sign in to comment.