aboutsummaryrefslogtreecommitdiffstats
path: root/filamento
diff options
context:
space:
mode:
Diffstat (limited to 'filamento')
-rw-r--r--filamento/Cargo.toml36
-rw-r--r--filamento/src/roster.rs36
2 files changed, 52 insertions, 20 deletions
diff --git a/filamento/Cargo.toml b/filamento/Cargo.toml
index 90d2d73..7d7af0c 100644
--- a/filamento/Cargo.toml
+++ b/filamento/Cargo.toml
@@ -15,10 +15,10 @@ opfs = ["dep:web-sys"]
reactive_stores = ["dep:reactive_stores"]
[dependencies]
-futures = "0.3.30"
-lampada = { version = "0.1.0", path = "../lampada" }
-thiserror = "2.0.11"
-stanza = { version = "0.1.0", path = "../stanza", features = [
+futures = { workspace = true }
+lampada = { workspace = true }
+thiserror = { workspace = true }
+stanza = { workspace = true, features = [
"rfc_6121",
"xep_0203",
"xep_0030",
@@ -30,21 +30,21 @@ stanza = { version = "0.1.0", path = "../stanza", features = [
"xep_0084",
] }
# TODO: re-export jid?
-jid = { version = "0.1.0", path = "../jid", features = ["rusqlite"] }
-uuid = { version = "1.13.1", features = ["v4"] }
+jid = { workspace = true, features = ["rusqlite"] }
+uuid = { workspace = true, features = ["v4"] }
rusqlite = { git = "https://github.com/Spxg/rusqlite.git", branch = "wasm-demo", features = [
"uuid",
"chrono",
] }
-tracing = "0.1.41"
-chrono = "0.4.40"
+tracing = { workspace = true }
+chrono = { workspace = true }
+serde = { workspace = true, features = ["derive"], optional = true }
sha2 = "0.10.8"
sha3 = "0.10.8"
base64 = "0.22.1"
sha1 = "0.10.6"
image = "0.25.6"
hex = "0.4.3"
-serde = { version = "1.0.219", features = ["derive"], optional = true }
reactive_stores = { version = "0.2.2", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
@@ -52,7 +52,7 @@ tokio = { workspace = true, features = ["sync", "time", "rt", "fs", "io-std"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["sync", "time", "rt"] }
-web-sys = { version = "0.3", features = [
+web-sys = { workspace = true, features = [
"FileSystemDirectoryHandle",
"FileSystemWritableFileStream",
"FileSystemGetDirectoryOptions",
@@ -63,22 +63,20 @@ web-sys = { version = "0.3", features = [
"Window",
"Navigator",
], optional = true }
-jid = { version = "0.1.0", path = "../jid", features = ["rusqlite"] }
-wasm-bindgen = "0.2"
-wasm-bindgen-futures = "0.4"
+wasm-bindgen = { workspace = true }
+wasm-bindgen-futures = { workspace = true }
rusqlite = { git = "https://github.com/Spxg/rusqlite.git", branch = "wasm-demo", features = [
"uuid",
"chrono",
"precompiled-wasm",
] }
-tokio_with_wasm = { version = "0.8.2", features = ["sync", "time", "rt"] }
+tokio_with_wasm = { workspace = true, features = ["sync", "time", "rt"] }
[dev-dependencies]
-tracing-subscriber = "0.3.19"
-peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" }
-tracing-wasm = "0.2.1"
-tokio_with_wasm = { version = "0.8.2", features = ["sync", "time", "rt"] }
-wasm-bindgen-test = "0.3.0"
+tracing-subscriber = { workspace = true }
+peanuts = { workspace = true }
+tracing-wasm = { workspace = true }
+wasm-bindgen-test = { workspace = true }
[[example]]
name = "example"
diff --git a/filamento/src/roster.rs b/filamento/src/roster.rs
index 284e2b8..6b61e10 100644
--- a/filamento/src/roster.rs
+++ b/filamento/src/roster.rs
@@ -1,4 +1,4 @@
-use std::collections::HashSet;
+use std::{collections::HashSet, fmt::Display};
use jid::JID;
use rusqlite::{
@@ -27,15 +27,25 @@ pub struct Contact {
}
#[derive(Debug, Clone, PartialEq, Eq)]
+/// Contact subscription state.
pub enum Subscription {
+ /// No subscriptions.
None,
+ /// Pending outgoing subscription request.
PendingOut,
+ /// Pending incoming subscription request.
PendingIn,
+ /// Pending incoming & pending outgoing subscription requests.
PendingInPendingOut,
+ /// Subscribed to.
OnlyOut,
+ /// Subscription from.
OnlyIn,
+ /// Subscribed to & pending incoming subscription request.
OutPendingIn,
+ /// Subscription from & pending outgoing subscription request.
InPendingOut,
+ /// Buddy (subscriptions both ways).
Buddy,
// TODO: perhaps don't need, just emit event to remove contact
// Remove,
@@ -81,6 +91,30 @@ impl FromSql for Subscription {
}
}
+impl Display for Subscription {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Subscription::None => write!(f, "No Subscriptions"),
+ Subscription::PendingOut => write!(f, "Pending Outgoing Subscription Request"),
+ Subscription::PendingIn => write!(f, "Pending Incoming Subscription Request"),
+ Subscription::PendingInPendingOut => write!(
+ f,
+ "Pending Incoming & Pending Outgoing Subscription Requests"
+ ),
+ Subscription::OnlyOut => write!(f, "Subscribed To"),
+ Subscription::OnlyIn => write!(f, "Subscription From"),
+ Subscription::OutPendingIn => {
+ write!(f, "Subscribed To & Pending Incoming Subscription Request")
+ }
+ Subscription::InPendingOut => write!(
+ f,
+ "Subscription From & Pending Outgoing Subscription Request"
+ ),
+ Subscription::Buddy => write!(f, "Buddy (Subscriptions Both Ways)"),
+ }
+ }
+}
+
// none
// >
// >>