udp_server
fast rust udp server
Examples echo
```rust
![feature(async_closure)]
use udp_server::UdpServer;
use std::cell::RefCell;
use std::error::Error;
[tokio::main]
async fn main()->Result<(),Box> {
let mut a = UdpServer::<_,_,i32>::new("0.0.0.0:5555").await?;
a.setinput(async move |,peer,data|{
peer.send(&data).await?;
Ok(())
});
a.start().await?;
Ok(())
}
```
if you need to use token
Examples token echo
```rust
![feature(async_closure)]
use udp_server::UdpServer;
use std::cell::RefCell;
use std::error::Error;
[tokio::main]
async fn main()->Result<(),Box> {
let mut a = UdpServer::new("0.0.0.0:5555").await?;
a.setinput(async move |,peer,data|{
let mut token = peer.token.lock().await;
match token.0 {
Some(ref mut x)=>{
*x+=1;
},
None=>{
token.0=Some(1);
}
}
peer.send(&data).await?;
Ok(())
});
a.start().await?;
Ok(())
}
```