Skip to content

Dynamic custom jet loader#13

Open
topologoanatom wants to merge 15 commits intodevelopmentfrom
feature/plugin-macro
Open

Dynamic custom jet loader#13
topologoanatom wants to merge 15 commits intodevelopmentfrom
feature/plugin-macro

Conversation

@topologoanatom
Copy link
Collaborator

Changes

Implemented:

  • jet_plugins::register_jets!: A macro that implements the Jet trait for user-defined functions, alongside a corresponding C interface.
  • core::jets::jet_dyn: A C interface for interacting with custom jets and their Jet trait implementations via dynamic libraries.
  • service::custom_jet: Glue code for re-importing Jet implementations from a dynamic library.
  • service::jet_backend: A wrapper to invoke default Elements jets if no dynamic library is provided via environment variables.

Currently, `decode` for custom jets does not
working. Probably bug in encoding tree pasted into
`decode_bits!`
Changed handle for FFI jet value since `Jet` trait
requires it to be `Copy`. It involves storing
index of jet's val inside `ALL` array.

`decode` func is mocked for now since I think it
worth just paste original Elements decode tree
inside and then implement it via fallback if
`Clone` will become available.

`c_jet_ptr` is also mocked because Box<dyn Fn...>
can't be used and I have not figured out how to
mitigate this issue.
Moving `BitIter<I>` via FFI was too complicated,
so I implemented auxiliar function
`decode_bool_iter`, which takes `&mut dyn Iterator
<Item = bool>`. It also stores entire encoding
tree, so is safe now. We can reimplement fallback
strategy if `Clone` on `BitIter` would become
available.

Custom jet codes now store 20 bits
(16 bits of hash + 4 bits of prefix)
@topologoanatom topologoanatom self-assigned this Mar 2, 2026
@topologoanatom topologoanatom added the enhancement New feature or request label Mar 2, 2026
@topologoanatom topologoanatom requested a review from ivanlele March 2, 2026 12:11
@ivanlele ivanlele marked this pull request as ready for review March 2, 2026 12:35
@ivanlele ivanlele changed the base branch from master to development March 4, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant