workspaceify

This commit is contained in:
lif 2023-11-12 16:18:55 -08:00
parent b3eb220359
commit 94f99e9f84
8 changed files with 64 additions and 15 deletions

20
Cargo.lock generated
View file

@ -2368,16 +2368,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "tubest"
name = "tubest-common"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "tubest-driver"
version = "0.1.0"
dependencies = [
"futures",
"libmpv",
"tokio",
"tokio-stream",
"tubest-common",
]
[[package]]
name = "tubest-matrix"
version = "0.1.0"
dependencies = [
"matrix-sdk",
"serde",
"serde_json",
"tokio",
"tokio-stream",
"tubest-common",
]
[[package]]

View file

@ -1,15 +1,17 @@
[package]
name = "tubest"
version = "0.1.0"
edition = "2021"
[workspace]
resolver = "2"
members = [
"common",
"matrix",
"driver",
]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[workspace.dependencies]
tubest-common = { path = "common" }
futures = { version = "0.3" }
libmpv = { git = "https://github.com/ParadoxSpiral/libmpv-rs", rev = "3e6c389b716f52a595cc5e8e3fa1f96cb76b3de7" }
matrix-sdk = { version = "0.6" }
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["full"] }
serde = { version = "1" }
serde_json = { version = "1" }
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["full"] }

7
common/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "tubest-common"
version = "0.1.0"
edition = "2021"
[dependencies]
serde.workspace = true

1
common/src/lib.rs Normal file
View file

@ -0,0 +1 @@
pub const PROG_NAME: &str = "tubest";

11
driver/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "tubest-driver"
version = "0.1.0"
edition = "2021"
[dependencies]
tubest-common.workspace = true
futures.workspace = true
libmpv.workspace = true
tokio.workspace = true
tokio-stream.workspace = true

11
matrix/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "tubest-matrix"
version = "0.1.0"
edition = "2021"
[dependencies]
tubest-common.workspace = true
matrix-sdk.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true

View file

@ -9,6 +9,7 @@ use matrix_sdk::{
use serde::{Deserialize, Serialize};
use std::io::Write;
use std::path::PathBuf;
use tubest_common::PROG_NAME;
#[derive(Serialize, Deserialize)]
struct Config {
@ -22,7 +23,7 @@ impl Config {
fn path() -> PathBuf {
#[allow(deprecated)]
let home = std::env::home_dir().expect("no coats and no home");
home.join(".config").join("tubest").join("matrix.json")
home.join(".config").join(PROG_NAME).join("matrix.json")
}
fn read() -> Self {
let path = Self::path();
@ -57,7 +58,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
client
.login_username(&cfg.user, cfg.password.as_ref().unwrap())
.device_id(session.device_id.as_str())
.initial_device_display_name("tubest")
.initial_device_display_name(PROG_NAME)
.request_refresh_token()
.send()
.await?;
@ -68,7 +69,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
if let Some(ref password) = cfg.password {
client
.login_username(&cfg.user, password)
.initial_device_display_name("tubest")
.initial_device_display_name(PROG_NAME)
.request_refresh_token()
.send()
.await?;
@ -80,7 +81,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
.devices
.into_iter()
.filter(|d| {
d.display_name.clone().unwrap_or_default().as_str() == "tubest"
d.display_name.clone().unwrap_or_default().as_str() == PROG_NAME
&& d.device_id != client.device_id().unwrap()
})
.map(|d| d.device_id)