From eff3b2960d8314a54e32fca2a33f456f79c24440 Mon Sep 17 00:00:00 2001 From: Jon Lamb Date: Fri, 5 Apr 2024 04:50:53 -0700 Subject: [PATCH] Migrate to auxon-sdk --- Cargo.lock | 214 ++++++++++++++++++++++++----------------- Cargo.toml | 15 ++- src/client.rs | 11 ++- src/config.rs | 20 ++-- src/context_manager.rs | 4 +- src/defmt_reader.rs | 4 +- src/error.rs | 6 +- src/event_record.rs | 3 +- 8 files changed, 157 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc1767f..5f72b49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,6 +152,33 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "auxon-sdk" +version = "1.2.1" +source = "git+https://github.com/auxoncorp/auxon-sdk.git?branch=client-utils#e19c4578e269a279ba17d3f0dcd18437187e8baa" +dependencies = [ + "clap", + "dirs", + "exitcode", + "futures", + "hex", + "lazy_static", + "minicbor", + "native-tls", + "nix 0.26.4", + "ordered-float", + "regex", + "serde", + "thiserror", + "tokio", + "tokio-native-tls", + "toml 0.5.11", + "tracing", + "tracing-subscriber", + "url", + "uuid", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -869,12 +896,48 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -894,6 +957,47 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1264,6 +1368,15 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "miette" version = "5.10.0" @@ -1342,45 +1455,12 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "modality-api" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "294614fb4a07f458e77ba9475ce63c9b676bcf0b55ceccae71ac4964dd04fc17" -dependencies = [ - "minicbor", - "ordered-float", - "thiserror", - "uuid", -] - -[[package]] -name = "modality-auth-token" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc09a3c4f29de19eb92df42b9369c4c7929b37ab1cde911243fe4f03756cdc42" -dependencies = [ - "dirs", - "hex", - "thiserror", -] - -[[package]] -name = "modality-auth-token" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbd3f6b291b19431b4dbaab7a73788e4778908a175c8e024c0a563de2b78dc6" -dependencies = [ - "dirs", - "hex", - "thiserror", -] - [[package]] name = "modality-defmt-plugins" version = "0.3.0" dependencies = [ "anyhow", + "auxon-sdk", "clap", "clap-stdin", "ctrlc", @@ -1390,11 +1470,6 @@ dependencies = [ "exitcode", "goblin", "humantime", - "modality-api", - "modality-auth-token 0.2.0", - "modality-ingest-client", - "modality-ingest-protocol", - "modality-reflector-config", "pretty_assertions", "probe-rs", "serde", @@ -1409,55 +1484,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "modality-ingest-client" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7236aecfb23dcd4a9d2771bfa79cfc77686d742190c650e518f9968ed4af6eba" -dependencies = [ - "minicbor", - "modality-api", - "modality-auth-token 0.1.1", - "modality-ingest-protocol", - "modality-reflector-config", - "native-tls", - "ordered-float", - "thiserror", - "tokio", - "tokio-native-tls", - "tracing", - "url", - "uuid", -] - -[[package]] -name = "modality-ingest-protocol" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021a4aef304f4a86336f4da540e4967805870e8c177f71f3f10c8d6b07161066" -dependencies = [ - "minicbor", - "modality-api", -] - -[[package]] -name = "modality-reflector-config" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "056025ca3c0a195526939e35b489e12b92357cbce2e406f5aa922e3f28c934c8" -dependencies = [ - "dirs", - "lazy_static", - "modality-api", - "modality-auth-token 0.1.1", - "regex", - "serde", - "thiserror", - "toml 0.5.11", - "tracing", - "url", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -1485,6 +1511,8 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", + "memoffset", + "pin-utils", ] [[package]] @@ -1632,9 +1660,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "2.10.1" +version = "3.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" dependencies = [ "num-traits", ] @@ -1684,6 +1712,12 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.30" diff --git a/Cargo.toml b/Cargo.toml index 00295b5..d563214 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,21 +30,17 @@ derive_more = "0.99" url = "2" uuid = { version = "1", features = ["v4", "serde"] } humantime = "2" -serde = { version = "1.0", features=["derive"] } +serde = { version = "1.0", features = ["derive"] } serde_with = "3.6" probe-rs = "0.23" -defmt-decoder = { git = "https://github.com/auxoncorp/defmt.git", branch = "decoder-changes", features=["unstable"] } -defmt-parser = { git = "https://github.com/auxoncorp/defmt.git", branch = "decoder-changes", features=["unstable"] } +defmt-decoder = { git = "https://github.com/auxoncorp/defmt.git", branch = "decoder-changes", features = ["unstable"] } +defmt-parser = { git = "https://github.com/auxoncorp/defmt.git", branch = "decoder-changes", features = ["unstable"] } goblin = "0.8" clap = { version = "4.5", features = ["derive", "env", "color"] } clap-stdin = "0.4" -ctrlc = { version = "3.4", features=["termination"] } +ctrlc = { version = "3.4", features = ["termination"] } exitcode = "1" -modality-api = "0.2" -modality-ingest-client = "0.3" -modality-ingest-protocol = "0.2" -modality-reflector-config = "0.3" -modality-auth-token = "0.2" +auxon-sdk = { version = "1.2", features = ["modality"] } [dev-dependencies] tempfile = "3.10" @@ -57,3 +53,4 @@ strip="debuginfo" [patch.crates-io] nusb = { git = "https://github.com/jonlamb-gh/nusb.git", branch = "update-ioctl-code" } +auxon-sdk = { git = "https://github.com/auxoncorp/auxon-sdk.git", branch = "client-utils" } diff --git a/src/client.rs b/src/client.rs index 9e2e103..778072a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,14 +1,15 @@ use crate::Error; -use modality_api::{AttrVal, TimelineId}; -use modality_ingest_client::dynamic::DynamicIngestClient; -use modality_ingest_client::{IngestClient, ReadyState}; -use modality_ingest_protocol::InternedAttrKey; +use auxon_sdk::{ + api::{AttrVal, TimelineId}, + ingest_client::{dynamic::DynamicIngestClient, IngestClient, ReadyState}, + ingest_protocol::InternedAttrKey, +}; use std::collections::BTreeMap; pub struct Client { timeline_keys: BTreeMap, event_keys: BTreeMap, - inner: DynamicIngestClient, + pub(crate) inner: DynamicIngestClient, } impl Client { diff --git a/src/config.rs b/src/config.rs index 0504cdc..23c61b1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,9 @@ use crate::opts::{DefmtOpts, ReflectorOpts, RtosMode}; +use auxon_sdk::{ + auth_token::AuthToken, + reflector_config::{Config, TomlValue, TopLevelIngest, CONFIG_ENV_VAR}, +}; use derive_more::{Deref, From, Into}; -use modality_auth_token::AuthToken; -use modality_reflector_config::{Config, TomlValue, TopLevelIngest, CONFIG_ENV_VAR}; use serde::Deserialize; use std::env; use std::path::{Path, PathBuf}; @@ -11,10 +13,10 @@ use url::Url; #[derive(Debug, thiserror::Error)] pub enum AuthTokenError { #[error(transparent)] - StringDeserialization(#[from] modality_auth_token::AuthTokenStringDeserializationError), + StringDeserialization(#[from] auxon_sdk::auth_token::AuthTokenStringDeserializationError), #[error(transparent)] - LoadAuthTokenError(#[from] modality_auth_token::LoadAuthTokenError), + LoadAuthTokenError(#[from] auxon_sdk::auth_token::LoadAuthTokenError), } #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] @@ -130,9 +132,9 @@ impl DefmtConfig { defmt_opts: DefmtOpts, ) -> Result> { let cfg = if let Some(cfg_path) = &rf_opts.config_file { - modality_reflector_config::try_from_file(cfg_path)? + auxon_sdk::reflector_config::try_from_file(cfg_path)? } else if let Ok(env_path) = env::var(CONFIG_ENV_VAR) { - modality_reflector_config::try_from_file(Path::new(&env_path))? + auxon_sdk::reflector_config::try_from_file(Path::new(&env_path))? } else { Config::default() }; @@ -183,7 +185,9 @@ impl DefmtConfig { pub fn resolve_auth(&self) -> Result { if let Some(auth_token_hex) = self.auth_token.as_deref() { - Ok(modality_auth_token::decode_auth_token_hex(auth_token_hex)?) + Ok(auxon_sdk::auth_token::decode_auth_token_hex( + auth_token_hex, + )?) } else { Ok(AuthToken::load()?) } @@ -288,7 +292,7 @@ impl PluginConfig { #[cfg(test)] mod test { use super::*; - use modality_reflector_config::{AttrKeyEqValuePair, TimelineAttributes}; + use auxon_sdk::reflector_config::{AttrKeyEqValuePair, TimelineAttributes}; use pretty_assertions::assert_eq; use std::{env, fs::File, io::Write}; diff --git a/src/context_manager.rs b/src/context_manager.rs index cc7d9d4..ff48117 100644 --- a/src/context_manager.rs +++ b/src/context_manager.rs @@ -1,5 +1,5 @@ use crate::{Error, EventRecord, PluginConfig, RtosMode}; -use modality_api::{AttrVal, BigInt, TimelineId}; +use auxon_sdk::api::{AttrVal, BigInt, TimelineId}; use std::collections::BTreeMap; use std::hash::{DefaultHasher, Hash, Hasher}; use tracing::{debug, trace, warn}; @@ -537,7 +537,7 @@ mod rtic1 { mod test { use super::*; use crate::opts::RtosMode; - use modality_api::BigInt; + use auxon_sdk::api::BigInt; use pretty_assertions::assert_eq; use tracing_test::traced_test; diff --git a/src/defmt_reader.rs b/src/defmt_reader.rs index 68bcd0e..a7f1e8a 100644 --- a/src/defmt_reader.rs +++ b/src/defmt_reader.rs @@ -2,8 +2,8 @@ use crate::{ Client, ContextEvent, ContextManager, DefmtConfig, Error, EventRecord, Interruptor, TimelineAttributes, TimelineMeta, }; +use auxon_sdk::ingest_client::IngestClient; use defmt_decoder::{DecodeError, Table}; -use modality_ingest_client::IngestClient; use std::collections::{BTreeMap, BTreeSet}; use std::{fs, io::Read, time::Duration}; use tracing::{debug, warn}; @@ -200,6 +200,8 @@ pub async fn run( .await?; } + //client.inner.flush().await()?; + if let Some(res) = maybe_read_result { res } else { diff --git a/src/error.rs b/src/error.rs index 8d1581e..d4e5e69 100644 --- a/src/error.rs +++ b/src/error.rs @@ -31,13 +31,13 @@ pub enum Error { Io(#[from] io::Error), #[error("Encountered an ingest client error. {0}")] - Ingest(#[from] modality_ingest_client::IngestError), + Ingest(#[from] auxon_sdk::ingest_client::IngestError), #[error("Encountered an ingest client error. {0}")] - DynamicIngest(#[from] modality_ingest_client::dynamic::DynamicIngestError), + DynamicIngest(#[from] auxon_sdk::ingest_client::dynamic::DynamicIngestError), #[error("Encountered an ingest client initialization error. {0}")] - IngestClientInitialization(#[from] modality_ingest_client::IngestClientInitializationError), + IngestClientInitialization(#[from] auxon_sdk::ingest_client::IngestClientInitializationError), #[error("Failed to authenticate. {0}")] Auth(#[from] crate::config::AuthTokenError), diff --git a/src/event_record.rs b/src/event_record.rs index 3c920a6..1f307b8 100644 --- a/src/event_record.rs +++ b/src/event_record.rs @@ -1,8 +1,7 @@ use crate::Error; +use auxon_sdk::api::{AttrVal, BigInt, Nanoseconds, TimelineId, Uuid}; use defmt_decoder::{Arg, Frame, Location}; use defmt_parser::{Fragment, ParserMode}; -use modality_api::Uuid; -use modality_api::{AttrVal, BigInt, Nanoseconds, TimelineId}; use std::collections::BTreeMap; use tracing::{debug, warn};