Support for supabase api

This commit is contained in:
2025-10-12 13:00:35 +02:00
parent 80be4b703d
commit 2561f886c6
7 changed files with 135 additions and 22 deletions
+9 -6
View File
@@ -11,8 +11,8 @@ use serde::{Deserialize, Serialize};
use crate::types::{ClientMessage, WsMessage};
pub mod handshake {
use base64::engine::general_purpose::STANDARD as Base64;
use base64::Engine;
use base64::engine::general_purpose::STANDARD as Base64;
use sha1::{Digest, Sha1};
use std::collections::HashMap;
use std::io::{BufRead, BufReader, Write};
@@ -100,7 +100,7 @@ pub mod handshake {
}
}
pub struct Client(TcpStream, Option<u32>, u64);
pub struct Client(TcpStream, Option<String>, u64);
impl Client {
/// Create a client with no timeouts
@@ -324,12 +324,15 @@ impl Client {
self.read_t()
}
pub fn get_uuid(&self) -> crate::Result<u32> {
self.1.ok_or(anyhow!("Invalid UUID"))
pub fn get_uuid(&self) -> crate::Result<String> {
match &self.1 {
Some(v) => Ok(v.clone()),
None => Err(anyhow!("Client ({}) UUID not set", self.2).into()),
}
}
pub fn set_uuid(&mut self, uuid: u32) {
self.1 = Some(uuid)
pub fn set_uuid(&mut self, uuid: &str) {
self.1 = Some(uuid.to_string())
}
#[deprecated]