#url #macro #http #parser #uller

过程宏 uller_macro

uller宏库

4个版本

0.1.21 2024年8月1日
0.1.2 2024年8月1日
0.1.1 2024年8月1日
0.1.0 2024年8月1日

2037过程宏

Download history 253/week @ 2024-07-29

每月253 次下载
用于 2 个crate(通过 uller

MIT 许可

14KB
219

Uller Macro

crate为uller提供有用的接口

Qller(默认)

示例

  use uller::prelude;
  #[derive(Qller)]
  #[url = "http://127.0.0.1:1234/"]
  struct Test {
      #[name = "f"] // rename to "f"
      f111: String,
      #[name = "v"] // rename to "v"
      #[pos = 0]    // move it to the first position
      v222: String,
  }

这将转换为 http://127.0.0.1:1234/?v={value}&f={value}

注意:位置从0开始,就像数组一样。

Juller(功能 - juller)

示例

  use uller::prelude;
  #[derive(Qller, Juller)]
  #[output = "TestOut"]
  #[url = "http://127.0.0.1:41112/"]
  struct Test {
      f: String,
      v: String,
  }
  #[derive(Deserialize, Debug)]
  struct TestOut {
      field: String,
  }
  async fn convert(st: &Test) -> TestOut {
      st.download().await.unwrap()
      // or
      st.download_verbose().await.unwrap()
  }

Buller(功能 - buller)

示例

  use uller::prelude;

  #[derive(Qller, Buller)]
  #[url = "http://127.0.0.1:41112/"]
  struct Test {
      f: String,
      v: String,
  }

  async fn convert(st: &Test) -> bytes::Bytes {
      st.download().await.unwrap()
      // or
      st.download_verbose().await.unwrap()
  }

依赖

~1.5MB
~35K SLoC