formatted some rust files for linting porpuses

This commit is contained in:
2026-03-24 16:44:22 -03:00
parent 5ffc08e6f1
commit f88c02a7aa
17 changed files with 317 additions and 303 deletions

View File

@@ -1,23 +1,23 @@
use std::net::{IpAddr, UdpSocket};
pub fn get_local_address() -> String {
fn get_local_ip() -> Result<IpAddr, String> {
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
socket.connect("8.8.8.8:80").map_err(|e| e.to_string())?;
socket
.local_addr()
.map(|addr| addr.ip())
.map_err(|e| e.to_string())
}
fn get_local_ip() -> Result<IpAddr, String> {
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
socket.connect("8.8.8.8:80").map_err(|e| e.to_string())?;
socket
.local_addr()
.map(|addr| addr.ip())
.map_err(|e| e.to_string())
}
let parsed_data = get_local_ip();
let parsed_data = get_local_ip();
match parsed_data {
Ok(ip) => {
return format!("ws://{}:4152", ip.to_string());
}
Err(_) => {
return "not provided".to_string();
}
}
match parsed_data {
Ok(ip) => {
return format!("ws://{}:4152", ip.to_string());
}
Err(_) => {
return "not provided".to_string();
}
}
}

View File

@@ -2,11 +2,11 @@ use crate::structs::LogPayload;
use log::{error, info, warn};
pub fn log_info(data: LogPayload) -> String {
match data.status.as_str() {
"info" => info!("{}", data.message),
"warn" => warn!("{}", data.message),
"error" => error!("{}", data.message),
_ => error!("{}", "Wrong log call"),
}
"logged".to_string()
}
match data.status.as_str() {
"info" => info!("{}", data.message),
"warn" => warn!("{}", data.message),
"error" => error!("{}", data.message),
_ => error!("{}", "Wrong log call"),
}
"logged".to_string()
}

View File

@@ -1,3 +1,3 @@
pub mod uuid;
pub mod address;
pub mod log;
pub mod log;
pub mod uuid;

View File

@@ -1,7 +1,7 @@
pub fn get_uuid() -> String {
use uuid::Uuid;
use uuid::Uuid;
let id = Uuid::new_v4().to_string();
let id = Uuid::new_v4().to_string();
return id;
return id;
}