[Fix] Clean
Some checks failed
CI / checks (push) Failing after 2m37s

This commit is contained in:
Alex 2026-08-19 11:46:40 +02:00
commit d11eb04d12
Signed by: alex
SSH key fingerprint: SHA256:D1+Ub8o0v4K5y1JNivW8IxEOelqLSvPmUzBbDIoZkRQ
13 changed files with 163 additions and 973 deletions

3
example/Cargo.lock generated
View file

@ -1314,6 +1314,7 @@ dependencies = [
name = "mtp-crypto"
version = "0.3.0"
dependencies = [
"argon2",
"base64 0.22.1",
"chacha20poly1305",
"ed25519-dalek",
@ -1337,7 +1338,6 @@ dependencies = [
name = "mtp-files"
version = "0.3.0"
dependencies = [
"argon2",
"mtp-crypto",
"rand",
"thiserror 2.0.20",
@ -1353,6 +1353,7 @@ dependencies = [
"mtp-crypto",
"mtp-transport",
"rand",
"thiserror 2.0.20",
"tokio",
"tracing",
"wtransport",

View file

@ -62,7 +62,7 @@ pub fn build_demo_message(
)
.add_typed_default(
DataType::Timestamp,
DataValue::UnsignedNumber(timestamp as u128),
DataValue::UnsignedNumber(timestamp),
)
.add_typed_default(DataType::Data, DataValue::Str("Hello, MTP!".into()))
.add_typed_default(DataType::Flags, DataValue::BoolTrue)

View file

@ -79,6 +79,7 @@ pub struct ClientMetrics {
}
impl ClientMetrics {
#[cfg(test)]
pub fn new() -> Self {
Self {
sessions: Vec::new(),

View file

@ -47,7 +47,7 @@ fn pong(tm: &TypeMap, data: impl Into<String>) -> Result<CommunicationValue, Str
CommunicationValue::from_comm(CommunicationType::Pong, tm)
.add_data(desc_id, DataValue::Str("MTP example response".into()))
.map_err(|e| e.to_string())?
.add_data(ts_id, DataValue::UnsignedNumber(now as u128))
.add_data(ts_id, DataValue::UnsignedNumber(now))
.map_err(|e| e.to_string())?
.add_data(data_id, DataValue::Str(data.into()))
.map_err(|e| e.to_string())
@ -388,7 +388,7 @@ pub fn process_and_respond(
let response = CommunicationValue::from_comm(CommunicationType::Pong, tm)
.add_data(desc_id, description)
.map_err(|e| e.to_string())?
.add_data(ts_id, DataValue::UnsignedNumber(now as u128))
.add_data(ts_id, DataValue::UnsignedNumber(now))
.map_err(|e| e.to_string())?
.add_data(
data_id,

View file

@ -100,10 +100,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
serde_json::to_string_pretty(&*db).ok()
};
if let Some(json) = json {
if let Err(error) = tokio::fs::write("clients.json", json).await {
eprintln!("Failed to persist clients.json: {error}");
}
if let Some(json) = json
&& let Err(error) = tokio::fs::write("clients.json", json).await
{
eprintln!("Failed to persist clients.json: {error}");
}
println!("Registered new client with ID: {id}");

View file

@ -108,6 +108,7 @@ pub struct ServerMetrics {
}
impl ServerMetrics {
#[cfg(test)]
pub fn new() -> Self {
Self {
inner: Mutex::new(Inner {
@ -218,6 +219,7 @@ impl ServerMetrics {
}
}
#[cfg(test)]
pub fn snapshot(&self) -> ServerMetricsFile {
let inner = self.inner.lock().unwrap();
self.to_file(&inner)
@ -553,11 +555,11 @@ mod tests {
let metrics = ServerMetrics::new();
for i in 0..3 {
let mut session = metrics.start_session(1000 + i as u64, format!("session {i}"));
let mut session = metrics.start_session(1000 + i, format!("session {i}"));
for _ in 0..(i + 1) * 2 {
session.record_message(Duration::from_millis(1 + i), true);
}
session.record_pipe((i as u64 + 1) * 1000);
session.record_pipe((i + 1) * 1000);
session.finish(format!("exit {i}"));
}