1 unstable release

0.3.1 Oct 27, 2024

#159 in #register

Download history 112/week @ 2024-10-26 6/week @ 2024-11-02

118 downloads per month
Used in tcp-struct

MIT license

11KB
229 lines

TCP-Struct

Access structs over TCP with 2 lines of code

Features

  • default = ["async-tcp"]
  • async-tcp

How to register?

#[register_impl]
impl MyStruct {
    pub async fn function1(self, input: u16) -> String { ... }
    pub async fn function2(self, input: u32) -> String { ... }
}

#[derive(TCPShare)]
struct MyStruct {}

How to use(Server)?

MyStruct::default().start(8082, "struct-version").await;

How to use(Client)?

let data = MyStruct::read(8082, "struct-version").function1(0);

Info

  • struct-version needs to be the same on both sides
  • the #[register_impl] needs to be above the #[derive(TCPShare)]
  • {MyStruct}Reader & {MyStruct}Writer structs are generated and therefor shouldnt be used
  • {MyStruct} start(self, port, identifier) & read(port, identifier) are generated and therefor shouldnt be used

Issues

  • the #[register_impl] needs to be above the #[derive(TCPShare)]
  • across files?

Dependencies

~1.5MB
~38K SLoC