Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capnp_conv review + cleanup #230

Open
6 tasks
realcr opened this issue Jul 16, 2019 · 1 comment
Open
6 tasks

capnp_conv review + cleanup #230

realcr opened this issue Jul 16, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@realcr
Copy link
Member

realcr commented Jul 16, 2019

Help required

capnp-conv was written very hastily, and some help is required with improving the code:

  • Code review + refactoring suggestions
  • A more extensive test suite, possibly using Quickcheck or proptest. I'm not sure which one to pick.
  • Better error messages
    • Marking the correct span when an error occurs.
    • Providing extra information in unimplemented!() calls.
  • Extra documentation

What is capnp_conv

capnp_conv is a procedural macro mechanism allowing to automatically derive capnproto serialization and deserialization glue code between Rust structs and capnp structs.

Example for usage (From offst-proto):

#[capnp_conv(crate::funder_capnp::request_send_funds_op)]
#[derive(Eq, PartialEq, Debug, Clone, Serialize, Deserialize)]
pub struct RequestSendFundsOp {
    pub request_id: Uid,
    pub src_hashed_lock: HashedLock,
    pub route: FriendsRoute,
    #[capnp_conv(with = Wrapper<u128>)]
    pub dest_payment: u128,
    #[capnp_conv(with = Wrapper<u128>)]
    pub total_dest_payment: u128,
    pub invoice_id: InvoiceId,
    #[capnp_conv(with = Wrapper<u128>)]
    pub left_fees: u128,
}

The user can then invoke: request_send_funds.to_capnp_bytes() or RequestSendFunds::from_capnp_bytes(...)

The design of capnp_conv is inspired by proto_conv.

capnp_conv is currently being used through the whole Offst codebase, mostly in offst-proto.

@realcr
Copy link
Member Author

realcr commented Jul 16, 2019

@pzmarzly : Do you want to take this issue? (Requires some familiarity with procedural macros)

@realcr realcr added the enhancement New feature or request label Jul 16, 2019
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

No branches or pull requests

1 participant