monorepo/visions/ui/src/client.rs

40 lines
875 B
Rust
Raw Normal View History

2025-02-19 02:36:01 +00:00
use gloo_net::http::Request;
use serde::Deserialize;
#[derive(Deserialize)]
enum AuthResponse {
Ok(SessionId),
PasswordReset(SessionId),
}
#[derive(Deserialize)]
struct SessionId(String);
enum ClientError {
Unauthorized,
}
#[derive(Deserialize)]
struct UserId(String);
#[derive(Deserialize)]
struct UserInfo {
id: UserId,
name: String,
}
trait Client {
async fn auth(username: String, password: String) -> Result<AuthResponse, ClientError>;
async fn list_users(session_id: SessionId) -> Result<Vec<UserInfo>, ClientError>;
}
impl Client for Connection {
async fn auth(username: String, password: String) -> Result<AuthResponse, ClientError> {
let request = Request::post("http://localhost:8001")
.body().unwrap();
}
async fn list_users(session_id: SessionId) -> Result<Vec<UserInfo>, ClientError> {
}
}