workspaceify
This commit is contained in:
parent
b3eb220359
commit
94f99e9f84
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -2368,16 +2368,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tubest"
|
name = "tubest-common"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tubest-driver"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"libmpv",
|
"libmpv",
|
||||||
|
"tokio",
|
||||||
|
"tokio-stream",
|
||||||
|
"tubest-common",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tubest-matrix"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
"matrix-sdk",
|
"matrix-sdk",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tubest-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
20
Cargo.toml
20
Cargo.toml
|
@ -1,15 +1,17 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "tubest"
|
resolver = "2"
|
||||||
version = "0.1.0"
|
members = [
|
||||||
edition = "2021"
|
"common",
|
||||||
|
"matrix",
|
||||||
|
"driver",
|
||||||
|
]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
[workspace.dependencies]
|
||||||
|
tubest-common = { path = "common" }
|
||||||
[dependencies]
|
|
||||||
futures = { version = "0.3" }
|
futures = { version = "0.3" }
|
||||||
libmpv = { git = "https://github.com/ParadoxSpiral/libmpv-rs", rev = "3e6c389b716f52a595cc5e8e3fa1f96cb76b3de7" }
|
libmpv = { git = "https://github.com/ParadoxSpiral/libmpv-rs", rev = "3e6c389b716f52a595cc5e8e3fa1f96cb76b3de7" }
|
||||||
matrix-sdk = { version = "0.6" }
|
matrix-sdk = { version = "0.6" }
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
tokio-stream = { version = "0.1", features = ["full"] }
|
|
||||||
serde = { version = "1" }
|
serde = { version = "1" }
|
||||||
serde_json = { version = "1" }
|
serde_json = { version = "1" }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
tokio-stream = { version = "0.1", features = ["full"] }
|
||||||
|
|
7
common/Cargo.toml
Normal file
7
common/Cargo.toml
Normal 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
1
common/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub const PROG_NAME: &str = "tubest";
|
11
driver/Cargo.toml
Normal file
11
driver/Cargo.toml
Normal 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
11
matrix/Cargo.toml
Normal 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
|
|
@ -9,6 +9,7 @@ use matrix_sdk::{
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use tubest_common::PROG_NAME;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -22,7 +23,7 @@ impl Config {
|
||||||
fn path() -> PathBuf {
|
fn path() -> PathBuf {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let home = std::env::home_dir().expect("no coats and no home");
|
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 {
|
fn read() -> Self {
|
||||||
let path = Self::path();
|
let path = Self::path();
|
||||||
|
@ -57,7 +58,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
client
|
client
|
||||||
.login_username(&cfg.user, cfg.password.as_ref().unwrap())
|
.login_username(&cfg.user, cfg.password.as_ref().unwrap())
|
||||||
.device_id(session.device_id.as_str())
|
.device_id(session.device_id.as_str())
|
||||||
.initial_device_display_name("tubest")
|
.initial_device_display_name(PROG_NAME)
|
||||||
.request_refresh_token()
|
.request_refresh_token()
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -68,7 +69,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
if let Some(ref password) = cfg.password {
|
if let Some(ref password) = cfg.password {
|
||||||
client
|
client
|
||||||
.login_username(&cfg.user, password)
|
.login_username(&cfg.user, password)
|
||||||
.initial_device_display_name("tubest")
|
.initial_device_display_name(PROG_NAME)
|
||||||
.request_refresh_token()
|
.request_refresh_token()
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -80,7 +81,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
.devices
|
.devices
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|d| {
|
.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()
|
&& d.device_id != client.device_id().unwrap()
|
||||||
})
|
})
|
||||||
.map(|d| d.device_id)
|
.map(|d| d.device_id)
|
Loading…
Reference in a new issue