diffr-plugin-sdk 0.1.1

The diffr plugin contract in Rust: one trait for native and WASM plugins.
Documentation
  • Coverage
  • 53.18%
    92 out of 173 items documented0 out of 67 items with examples
  • Size
  • Source code size: 87.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.8 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • thesiti92

The diffr plugin contract in Rust. wit/plugin.wit in the diffr repository is the contract; this crate is its one Rust form, shared by every plugin whether diffr compiles it in or runs it as a WASM component.

  • [types] holds the contract's records: the file entry, each side's flat preorder region list with parent ids and text, and the moves. They are generated from wit/plugin.wit itself, so there is one definition of each, and a plugin hands diffr the same records natively and as a component.
  • [Plugin] is the one trait every plugin implements: new, which makes it from its options, queries, then classify and mutate, taking and returning exactly those records.
  • [host] holds what diffr gives every plugin: git.
  • [export!] makes a plugin the plugin resource a component exports when the crate is built for wasm32-wasip2, and otherwise exposes its native registration for the host to collect. The same source builds both ways.

Plugins reason about regions with the same code:

  • [tree] rebuilds a side's list as a tree ([tree::sides], which the SDK calls on the way in so a plugin is handed [Pairing] of [Source] rather than the flat records) and holds the helpers for reading trees ([walk], [OtherSide], [one_sided], [docstring_of], and the rest).
  • [apply] carries moves out. diffr carries every plugin's moves out with it, so [Draft], which carries a plugin's moves out on a copy as it makes them, and [apply::Fresh], which predicts fresh ids, give a plugin exactly the ids diffr will.