Giter Site home page Giter Site logo

binance.rs's People

Watchers

 avatar  avatar  avatar

Forkers

ljb1002123

binance.rs's Issues

Rest interface proc-macro to reduce the builder implementation redundancy

At a glance, the template code is below

#[derive(Debug, RestApi, Default)]
#[rest(uri="rest_api/path")
#[rest(method="GET")
#[rest(signature="USER_DATA")]
pub struct SomeRestApiName {
        // we belive that every field should implement the Default trait as default value 
        // else use Option as optional semantic
        field1: String,
        field2: Option<i32>,
        // other fields
}

Then we should get the api class with builder as below:

impl RestApi for SomeRestApiName {
         fn uri(&self) -> String { // return the uri in attribute }
         fn method(&self) -> reqwest::Method { // return the method in attribute }
         fn wait_to_sign(&self) -> Option<String> {
                    // hmacsha256 for USER_DATA in binance defined
         }
         fn query() -> Option<String>
         fn body() -> Option<String>
        
}

impl SomeRestApiName {
       pub fn new() -> Self; // Default ?
       pub fn field1(mut self, type) -> Self;
       pub fn field2(mut self, type) -> Self; 
}

So we could use this directly in Client look like this

async fn main() {
      async {
              let mut request = SomeRestApiName::new()
                                            .field1(xxxx)
                                            .field2(xxx);
             client.execute(&request).unwrap();
      }
}
  • introduce the proc_macro crate for describe this issue
  • full-test for anything

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.