initial commit
This commit is contained in:
parent
8522dd3f40
commit
b08b6de26d
7 changed files with 1421 additions and 1 deletions
13
api/Cargo.toml
Normal file
13
api/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.5.1"
|
||||
anyhow = "1.0.81"
|
||||
serde = "1.0.197"
|
||||
uuid = {version = "1.8.0", features = ["v4"]}
|
||||
|
31
api/src/endpoints.rs
Normal file
31
api/src/endpoints.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use actix_web::{web, App, HttpServer, Responder, HttpResponse};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use uuid::Uuid;
|
||||
use std::sync::mutex;
|
||||
use anyhow::Result;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct User {
|
||||
uuid: Uuid,
|
||||
server: Server
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Server {
|
||||
address: String
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Relay {
|
||||
uuid: Uuid,
|
||||
name: String,
|
||||
members: Mutex<Vec<User>>
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
struct AppState {
|
||||
users: Mutex<Vec<User>>,
|
||||
relays: Mutex<Vec<Relay>>
|
||||
}
|
||||
|
||||
|
14
api/src/lib.rs
Normal file
14
api/src/lib.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue