Git Product home page Git Product logo

Comments (2)

Kixunil avatar Kixunil commented on August 15, 2024 1

FYI I dug a bit into the API and I realized I don't like the duplication around is_known and the other methods since it can cause bugs. I think I will want to change it to something like:

struct ParamSlot<'a, 'b>(&'a mut Option<Param<'b>>);

impl<'a, 'b> ParamSlot<'a, 'b> {
    pub fn param_known(self) -> Param<'b> { self.0.take() }
}

trait DeserializationState<'de>: Default {
    fn deserialize_borrowed<'a>(&mut self, key: &str, value: ParamSlot<'a, 'de>) -> Result<ParamKind<'a, 'de>, (<Self::Value as DeserializationError>::Error, ParamSlot<'a, 'de>)> {
    self.deserialize_temp(key, value)
}

    fn deserialize_temp<'a, 'b>(&mut self, key: &str, value: ParamSlot<'a, 'b>) -> Result<ParamKind<'a, 'b>, (<Self::Value as DeserializationError>::Error, ParamSlot<'a, 'b>)>;
}

Also DeserializationError seems to exist because of lack of GAT, so I'd love to bump MSRV eventually.

from bip21.

Kixunil avatar Kixunil commented on August 15, 2024

Damn, I saw this issue before but I couldn't react for some reason and then forgot. :(

I was hoping that writing "It's inspired by serde" would make it obvious. We do it exactly like serde does, with macros. We can do either declarative or procedural. I personally prefer declarative but I know many people will want procedural, so I'll be happy to see anyone contributing that.

Here's a relevant part I wrote in the silent payment issue:

The way you compose it is you define struct MyParams { payjoin: Option<PjParams>, lightning: Option<LnParams> } (possibly Option<Result<_, _>> instead) and make DeserializationState contain states of both, you then try to feed the parameters into each and call finalize of each at the end. Allowing this is also the reason for the is_param_known method.

from bip21.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.