Add a README about changing capnp schema (#4998)

* Add a README about changing schema

* Add example PRs
This commit is contained in:
Jakub Žádník 2022-03-28 03:02:19 +03:00 committed by GitHub
parent 5586d4a0a0
commit 047081fa72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,18 @@
# nu-plugin
## Updating Cap'n Proto schema
When modifying a protocol's struct that is used in plugins (such as Signature), you need to update the capnproto schema file and recompile it into the Rust source code.
The steps are as follows:
1. Change `src/serializers/capnp/schema/plugin.capnp` as necessary
2. Install `capnp` tool (it's a C++ binary, commonly available in package managers)
3. Install Rust support for `capnp` called `capnpc-rust`:
1. `git clone https://github.com/capnproto/capnproto-rust` somewhere
2. `cd capnproto-rust/capnpc`
3. `cargo install --path=.`
4. Then, call `capnp compile -orust plugin.capnp` (change path as necessary)
5. The result should be `plugin_capnp.rs` file: Use it to replace the old `src/plugin_capnp.rs`.
6. It needs to be autoformatted (`cargo fmt --all`)
7. Modify the serialize/deserialize functions. Check the following PRs for details:
* https://github.com/nushell/nushell/pull/4980
* https://github.com/nushell/nushell/pull/4920