diff --git a/Cargo.lock b/Cargo.lock index d5056aeaa..2d9b1229b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,6 +292,15 @@ dependencies = [ "syn", ] +[[package]] +name = "atomic-polyfill" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" +dependencies = [ + "critical-section", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -524,6 +533,16 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2 0.10.9", + "tinyvec", +] + [[package]] name = "built" version = "0.8.1" @@ -590,6 +609,16 @@ dependencies = [ "shlex", ] +[[package]] +name = "celes" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55028d5b1eebb35237512a3838ce5583211434a233c8bb179551a7197ffb7bd4" +dependencies = [ + "phf", + "serde", +] + [[package]] name = "cfb" version = "0.7.3" @@ -696,6 +725,15 @@ dependencies = [ "cc", ] +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -831,6 +869,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "crossbeam-deque" version = "0.8.6" @@ -1224,6 +1268,18 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -1674,6 +1730,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "hash32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -1701,6 +1766,20 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +[[package]] +name = "heapless" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +dependencies = [ + "atomic-polyfill", + "hash32", + "rustc_version", + "serde", + "spin", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.4.1" @@ -2379,6 +2458,12 @@ dependencies = [ "include_dir", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -2459,6 +2544,15 @@ dependencies = [ "weezl", ] +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "lru-slab" version = "0.1.2" @@ -2888,7 +2982,16 @@ dependencies = [ "symphonia", "tokio", "tracing", - "uuid", +] + +[[package]] +name = "nvisy-context" +version = "0.1.0" +dependencies = [ + "async-trait", + "hipstr", + "nvisy-core", + "unicode-segmentation", ] [[package]] @@ -2897,6 +3000,7 @@ version = "0.1.0" dependencies = [ "async-trait", "bytes", + "celes", "derive_builder", "derive_more", "hipstr", @@ -2906,7 +3010,6 @@ dependencies = [ "serde_json", "strum 0.28.0", "thiserror", - "tracing", "type-map", "uuid", ] @@ -2947,8 +3050,6 @@ dependencies = [ "tokio-util", "toml", "tracing", - "type-map", - "unicode-normalization", "uuid", "validator", ] @@ -2988,7 +3089,6 @@ dependencies = [ "toml", "tracing", "unicode-normalization", - "uuid", ] [[package]] @@ -3012,7 +3112,6 @@ name = "nvisy-ocr" version = "0.1.0" dependencies = [ "async-trait", - "base64", "bentoml", "bytes", "futures", @@ -3028,15 +3127,17 @@ version = "0.1.0" dependencies = [ "aho-corasick", "async-trait", + "bs58", "csv", "derive_builder", + "derive_more", + "nvisy-context", "nvisy-core", + "phonenumber", "regex", - "schemars", "serde", "tokio", "toml", - "type-map", ] [[package]] @@ -3045,7 +3146,6 @@ version = "0.1.0" dependencies = [ "aide", "axum", - "base64", "derive_more", "futures", "humantime-serde", @@ -3053,7 +3153,6 @@ dependencies = [ "nvisy-core", "nvisy-engine", "schemars", - "semver", "serde", "tokio", "tower", @@ -3080,9 +3179,8 @@ dependencies = [ "aes-gcm", "async-trait", "base64", - "bytes", - "hipstr", "nvisy-codec", + "nvisy-context", "nvisy-core", "nvisy-fake", "nvisy-llm", @@ -3090,6 +3188,7 @@ dependencies = [ "nvisy-ocr", "nvisy-pattern", "nvisy-stt", + "regex", "schemars", "serde", "serde_json", @@ -3113,6 +3212,12 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "oncemutex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d11de466f4a3006fe8a5e7ec84e93b79c70cb992ae0aa0eb631ad2df8abfe2" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -3272,6 +3377,26 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phonenumber" +version = "0.3.9+9.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9114f9c1683dd09c5f4fa024c89fdad783eaae21d3d52dd23ddaaffa29ffb168" +dependencies = [ + "either", + "fnv", + "nom 7.1.3", + "once_cell", + "postcard", + "quick-xml", + "regex", + "regex-cache", + "serde", + "serde_derive", + "strum 0.27.2", + "thiserror", +] + [[package]] name = "pin-project" version = "1.1.13" @@ -3356,6 +3481,19 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "heapless", + "serde", +] + [[package]] name = "potential_utf" version = "0.1.5" @@ -3495,6 +3633,15 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +[[package]] +name = "quick-xml" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c" +dependencies = [ + "memchr", +] + [[package]] name = "quick_cache" version = "0.6.23" @@ -3788,7 +3935,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax", + "regex-syntax 0.8.10", ] [[package]] @@ -3799,7 +3946,19 @@ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.10", +] + +[[package]] +name = "regex-cache" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f7b62d69743b8b94f353b6b7c3deb4c5582828328bcb8d5fedf214373808793" +dependencies = [ + "lru-cache", + "oncemutex", + "regex", + "regex-syntax 0.6.29", ] [[package]] @@ -3808,6 +3967,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.10" @@ -4609,6 +4774,9 @@ name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros 0.27.2", +] [[package]] name = "strum" diff --git a/Cargo.toml b/Cargo.toml index 9a236f0f6..ee8f20008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ resolver = "3" members = [ "./crates/nvisy-cli", "./crates/nvisy-codec", + "./crates/nvisy-context", "./crates/nvisy-core", "./crates/nvisy-engine", "./crates/nvisy-fake", @@ -37,44 +38,22 @@ documentation = "https://docs.rs/nvisy-runtime" # Internal crates nvisy-codec = { path = "./crates/nvisy-codec", version = "0.1.0", default-features = false } +nvisy-context = { path = "./crates/nvisy-context", version = "0.1.0" } nvisy-core = { path = "./crates/nvisy-core", version = "0.1.0" } nvisy-engine = { path = "./crates/nvisy-engine", version = "0.1.0" } nvisy-fake = { path = "./crates/nvisy-fake", version = "0.1.0" } nvisy-llm = { path = "./crates/nvisy-llm", version = "0.1.0" } -nvisy-stt = { path = "./crates/nvisy-stt", version = "0.1.0" } -nvisy-toolkit = { path = "./crates/nvisy-toolkit", version = "0.1.0" } nvisy-ner = { path = "./crates/nvisy-ner", version = "0.1.0" } nvisy-ocr = { path = "./crates/nvisy-ocr", version = "0.1.0" } nvisy-pattern = { path = "./crates/nvisy-pattern", version = "0.1.0" } nvisy-server = { path = "./crates/nvisy-server", version = "0.1.0" } +nvisy-stt = { path = "./crates/nvisy-stt", version = "0.1.0" } +nvisy-toolkit = { path = "./crates/nvisy-toolkit", version = "0.1.0" } -# Inference & AI frameworks -bentoml = { version = "0.5", default-features = false, features = ["rustls-tls", "tracing"] } -rig = { version = "0.38", features = [], default-features = false } - -# HTTP client and middleware -reqwest = { version = "0.13", default-features = false, features = ["json", "rustls", "multipart"] } -reqwest-middleware = { version = "0.5", features = ["json", "multipart"] } -reqwest-retry = { version = "0.9", features = [] } -reqwest-tracing = { version = "0.7", features = [] } - -# Async runtime and parallelism -tokio = { version = "1.50", features = [] } -tokio-util = { version = "0.7", features = [] } -futures = { version = "0.3", features = [] } -async-trait = { version = "0.1", features = [] } -rayon = { version = "1.10", features = [] } - -# Observability -tracing = { version = "0.1", features = ["attributes"] } -tracing-subscriber = { version = "0.3", features = [] } - -# (De)serialization +# Serialization serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = [] } -serde_with = { version = "3.18", features = [] } schemars = { version = "1.0", features = ["uuid1", "bytes1"] } -csv = { version = "1.0", features = [] } toml = { version = "1.1", features = [] } minijinja = { version = "2.5", features = [] } @@ -92,38 +71,48 @@ hipstr = { version = "0.8", features = ["serde"] } jiff = { version = "0.2", features = ["serde"] } semver = { version = "1.0", features = ["serde"] } oxilangtag = { version = "0.1", features = ["serde"] } +celes = { version = "2.8", features = [] } humantime = { version = "2.1", features = [] } humantime-serde = { version = "1.1", features = [] } type-map = { version = "0.5", features = [] } # Encoding and hashing base64 = { version = "0.22", features = [] } +hex = { version = "0.4", features = [] } sha2 = { version = "0.11", features = [] } aes-gcm = { version = "0.10", features = [] } -hmac = { version = "0.13", features = [] } -hex = { version = "0.4", features = [] } -# Pattern matching +# Async runtime and parallelism +tokio = { version = "1.50", features = [] } +tokio-util = { version = "0.7", features = [] } +futures = { version = "0.3", features = [] } +async-trait = { version = "0.1", features = [] } +rayon = { version = "1.10", features = [] } + +# Observability +tracing = { version = "0.1", features = ["attributes"] } +tracing-subscriber = { version = "0.3", features = [] } + +# Text processing (pattern matching, language detection, unicode) regex = { version = "1.0", features = [] } aho-corasick = { version = "1.0", features = [] } -smallvec = { version = "1.13", features = [] } - -# Language detection and text segmentation lingua = { version = "1.8", default-features = false, features = ["english"] } -stop-words = { version = "0.10", features = ["iso"] } unicode-segmentation = { version = "1.13", features = [] } unicode-normalization = { version = "0.1", features = [] } -# PDF processing (parsing, text extraction, page-to-image rendering) -lopdf = { version = "0.41", features = [] } -pdfium-render = { version = "0.9", features = [] } +# Checksum / encoding +bs58 = { version = "0.5", features = ["check"] } +phonenumber = { version = "0.3", default-features = false } -# Document parsing +# Tabular document parsing +csv = { version = "1.0", features = [] } +calamine = { version = "0.35", features = [] } + +# Rich-document parsing (HTML, PDF) scraper = { version = "0.27", features = [] } ego-tree = { version = "0.11", features = [] } -calamine = { version = "0.35", features = [] } -zip = { version = "8.4", features = [] } -quick-xml = { version = "0.40", features = [] } +lopdf = { version = "0.41", features = [] } +pdfium-render = { version = "0.9", features = [] } # Image processing image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tiff"] } @@ -134,27 +123,30 @@ hound = { version = "3.5", features = [] } symphonia = { version = "0.6", default-features = false, features = ["wav", "pcm", "mp3"] } mp3lame-encoder = { version = "0.2", features = [] } -# CLI -clap = { version = "4.6", features = [] } +# AI / LLM frameworks +bentoml = { version = "0.5", default-features = false, features = ["rustls-tls", "tracing"] } +rig = { version = "0.38", features = [], default-features = false } + +# HTTP client and middleware +reqwest-middleware = { version = "0.5", features = ["json", "multipart"] } +reqwest-retry = { version = "0.9", features = [] } +reqwest-tracing = { version = "0.7", features = [] } -# HTTP server +# HTTP server and middleware axum = { version = "0.8", features = [] } aide = { version = "0.16.0-alpha.2", features = [] } tower = { version = "0.5", features = [] } tower-http = { version = "0.6", features = [] } -# Filesystem traversal -walkdir = { version = "2.5", features = [] } +# CLI +clap = { version = "4.6", features = [] } -# Storage, file detection, and asset embedding +# Storage and file-type detection fjall = { version = "3.1", features = [] } -include_dir = { version = "0.7", features = [] } infer = { version = "0.19", features = [] } # Utilities validator = { version = "0.20", features = ["derive"] } rand = { version = "0.10", features = [] } tempfile = { version = "3.27", features = [] } - -# Fake data generation fake = { version = "5.1", features = [] } diff --git a/crates/nvisy-cli/Cargo.toml b/crates/nvisy-cli/Cargo.toml index 7bb728cbb..c8fa9aec5 100644 --- a/crates/nvisy-cli/Cargo.toml +++ b/crates/nvisy-cli/Cargo.toml @@ -58,20 +58,16 @@ path = "src/main.rs" nvisy-engine = { workspace = true, features = [] } nvisy-server = { workspace = true, features = [] } -# CLI -clap = { workspace = true, features = ["derive", "env"] } - -# (De)serialization +# Serialization serde = { workspace = true, features = [] } toml = { workspace = true, features = [] } -humantime = { workspace = true, features = [] } humantime-serde = { workspace = true, features = [] } # Derive macros and error handling anyhow = { workspace = true, features = [] } -# HTTP server -axum = { workspace = true, features = ["tokio"] } +# Primitive datatypes +humantime = { workspace = true, features = [] } # Async runtime and parallelism tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] } @@ -80,5 +76,11 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] } tracing = { workspace = true, features = [] } tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } +# HTTP server and middleware +axum = { workspace = true, features = ["tokio"] } + +# CLI +clap = { workspace = true, features = ["derive", "env"] } + [package.metadata.cargo-machete] ignored = ["humantime-serde"] diff --git a/crates/nvisy-codec/Cargo.toml b/crates/nvisy-codec/Cargo.toml index c94df43b1..ff9752965 100644 --- a/crates/nvisy-codec/Cargo.toml +++ b/crates/nvisy-codec/Cargo.toml @@ -100,27 +100,39 @@ rustdoc-args = ["--cfg", "docsrs"] # Internal crates nvisy-core = { workspace = true, features = [] } -# Async runtime -async-trait = { workspace = true, features = [] } -tokio = { workspace = true, features = ["sync"] } - -# (De)serialization +# Serialization serde = { workspace = true, features = [] } serde_json = { workspace = true, features = [] } +schemars = { workspace = true, features = [] } + +# Derive macros and error handling +derive_more = { workspace = true, features = ["as_ref", "deref", "from"] } # Primitive datatypes bytes = { workspace = true, features = [] } -uuid = { workspace = true, features = [] } -derive_more = { workspace = true, features = ["as_ref", "deref", "from"] } + +# Encoding and hashing hex = { workspace = true, features = [] } -infer = { workspace = true, features = [] } -schemars = { workspace = true, features = [] } sha2 = { workspace = true, features = [] } -# Image processing — pulled in unconditionally because the image -# handler structs reference `image::DynamicImage` directly. The -# workspace dep already enables png/jpeg/tiff decoders. `imageproc` -# powers the per-region gaussian blur in `image::redact`. +# Async runtime and parallelism +async-trait = { workspace = true, features = [] } +tokio = { workspace = true, features = ["sync"] } +rayon = { workspace = true, optional = true, features = [] } + +# Observability +tracing = { workspace = true, features = [] } + +# Tabular document parsing (feature-gated) +csv = { workspace = true, optional = true, features = [] } + +# Rich-document parsing (feature-gated: HTML + PDF) +scraper = { workspace = true, optional = true, features = [] } +ego-tree = { workspace = true, optional = true, features = [] } +lopdf = { workspace = true, optional = true, features = [] } +pdfium-render = { workspace = true, optional = true, features = [] } + +# Image processing image = { workspace = true, features = [] } imageproc = { workspace = true, features = [] } @@ -129,18 +141,8 @@ hound = { workspace = true, optional = true, features = [] } symphonia = { workspace = true, optional = true, features = [] } mp3lame-encoder = { workspace = true, optional = true, features = [] } -# PDF processing (feature-gated) -lopdf = { workspace = true, optional = true, features = [] } -pdfium-render = { workspace = true, optional = true, features = [] } -rayon = { workspace = true, optional = true, features = [] } - -# Document parsing (feature-gated) -csv = { workspace = true, optional = true, features = [] } -scraper = { workspace = true, optional = true, features = [] } -ego-tree = { workspace = true, optional = true, features = [] } - -# Observability -tracing = { workspace = true, features = [] } +# Storage and file-type detection +infer = { workspace = true, features = [] } [dev-dependencies] tokio = { workspace = true, features = ["macros", "rt"] } diff --git a/crates/nvisy-codec/src/core/handler.rs b/crates/nvisy-codec/src/core/handler.rs index 83106862e..9ecd97b6c 100644 --- a/crates/nvisy-codec/src/core/handler.rs +++ b/crates/nvisy-codec/src/core/handler.rs @@ -29,13 +29,21 @@ use crate::content::{ContentData, ContentSource}; /// /// `data` is the per-modality wire payload; `location` is the /// coordinate the handler will accept in [`Handler::read`] / -/// [`Handler::redact`] to address the same chunk again. +/// [`Handler::redact`] to address the same chunk again. `hints` +/// carries out-of-band context strings the chunk's structural +/// neighbours surface — CSV/XLSX column headers, JSON object +/// keys, HTML parent-element text — for downstream context-aware +/// recognizers; handlers without such metadata leave it empty. #[derive(Debug, Clone, PartialEq)] pub struct Chunk { /// Coordinate addressing this chunk inside the handler. pub location: M::Location, /// Wire payload at the chunk's location. pub data: M::Data, + /// Out-of-band context strings recognizers should treat as + /// in-context (column headers, parent element text, …). + /// Empty when the handler has no such metadata to surface. + pub hints: Vec, } /// Per-modality capability trait every format handler implements. diff --git a/crates/nvisy-codec/src/core/loader.rs b/crates/nvisy-codec/src/core/loader.rs index bd3e0a4f4..f0dc51200 100644 --- a/crates/nvisy-codec/src/core/loader.rs +++ b/crates/nvisy-codec/src/core/loader.rs @@ -22,6 +22,7 @@ //! [`Format::loader`]: super::Format::loader //! [`FormatId`]: super::FormatId +use std::marker::PhantomData; use std::sync::Arc; use nvisy_core::Error; @@ -100,7 +101,7 @@ where { Arc::new(LoaderAdapter { loader, - _phantom: std::marker::PhantomData, + _phantom: PhantomData, }) } @@ -109,7 +110,7 @@ where /// [`erase`]; not part of the public API. struct LoaderAdapter> { loader: L, - _phantom: std::marker::PhantomData M>, + _phantom: PhantomData M>, } #[async_trait::async_trait] diff --git a/crates/nvisy-codec/src/document/mod.rs b/crates/nvisy-codec/src/document/mod.rs index 7afdcff4d..7d0a668f4 100644 --- a/crates/nvisy-codec/src/document/mod.rs +++ b/crates/nvisy-codec/src/document/mod.rs @@ -29,6 +29,9 @@ mod tabular; #[cfg(feature = "internal_text")] mod text; +use std::any::type_name; +use std::fmt; + use derive_more::From; #[cfg(feature = "internal_audio")] use nvisy_core::modality::Audio; @@ -226,11 +229,11 @@ impl DocumentHandle { } } -impl std::fmt::Debug for DocumentHandle { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl fmt::Debug for DocumentHandle { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("DocumentHandle") .field("format_id", &self.format_id) - .field("modality", &std::any::type_name::()) + .field("modality", &type_name::()) .finish() } } diff --git a/crates/nvisy-codec/src/handler/audio/mp3_codec.rs b/crates/nvisy-codec/src/handler/audio/mp3_codec.rs index ed59c87d5..e8b6f7984 100644 --- a/crates/nvisy-codec/src/handler/audio/mp3_codec.rs +++ b/crates/nvisy-codec/src/handler/audio/mp3_codec.rs @@ -16,12 +16,13 @@ //! redaction of MP3 streams. Callers wanting bit-perfect preservation //! of unredacted regions should not round-trip. -use std::io::Cursor; +use std::io::{Cursor, ErrorKind as IoErrorKind}; use bytes::Bytes; use mp3lame_encoder::{Builder, FlushNoGap, InterleavedPcm, MonoPcm}; use nvisy_core::Error; -use symphonia::core::audio::{Audio as _, GenericAudioBufferRef}; +use symphonia::core::audio::conv::{ConvertibleSample, FromSample}; +use symphonia::core::audio::{Audio as _, AudioBuffer, GenericAudioBufferRef}; use symphonia::core::codecs::audio::AudioDecoderOptions; use symphonia::core::errors::Error as SymError; use symphonia::core::formats::probe::Hint; @@ -139,9 +140,7 @@ pub(super) fn decode_to_pcm(bytes: &Bytes) -> Result { let packet = match reader.next_packet() { Ok(Some(p)) => p, Ok(None) => break, - Err(SymError::IoError(io_err)) - if io_err.kind() == std::io::ErrorKind::UnexpectedEof => - { + Err(SymError::IoError(io_err)) if io_err.kind() == IoErrorKind::UnexpectedEof => { break; } Err(e) => { @@ -198,14 +197,12 @@ fn append_interleaved_f32( channels: usize, out: &mut Vec, ) { - use symphonia::core::audio::conv::ConvertibleSample; - fn extend( - buf: &symphonia::core::audio::AudioBuffer, + buf: &AudioBuffer, channels: usize, out: &mut Vec, ) where - f32: symphonia::core::audio::conv::FromSample, + f32: FromSample, { let frames = buf.frames(); out.reserve(frames * channels); @@ -213,7 +210,7 @@ fn append_interleaved_f32( for ch in 0..channels { let plane = buf.plane(ch).expect("plane for known channel index"); let sample = plane[frame]; - out.push(>::from_sample(sample)); + out.push(>::from_sample(sample)); } } } diff --git a/crates/nvisy-codec/src/handler/audio/mp3_handler.rs b/crates/nvisy-codec/src/handler/audio/mp3_handler.rs index e3d376a65..c0b834229 100644 --- a/crates/nvisy-codec/src/handler/audio/mp3_handler.rs +++ b/crates/nvisy-codec/src/handler/audio/mp3_handler.rs @@ -108,7 +108,11 @@ impl Handler