[package]
name = "mzdata"
version = "0.63.3"
edition = "2021"
keywords = ['mass-spectrometry', 'mzml', 'mgf']

categories = ["science", "parser-implementations", "data-structures"]

description = "A library to read mass spectrometry data formats and a data model for mass spectra"

license = "Apache-2.0"

repository = "https://github.com/mobiusklein/mzdata"
documentation = "https://docs.rs/mzdata"

exclude = ["tmp/*", "test/data/*"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "mzdata"
# src = "src/main.rs"

[[example]]
name = "async_mzcat"
required-features = ["async"]

[[example]]
name = "mzcat"
required-features = ["parallelism"]

[[example]]
name = "averaging_writer"
required-features = ["parallelism", "mzsignal", "nalgebra"]

[[example]]
name = "random_access_iter"
required-features = ["nalgebra"]
doc-scrape-examples = true

[[example]]
name = "mzinfo"
doc-scrape-examples = true

[[example]]
name = "mzconvert"
doc-scrape-examples = true

[lib]
name = "mzdata"
# src = "src/lib.rs"

[profile.release]
lto = true
debug = true

[features]
# default = ["nalgebra", "parallelism", "mzsignal", "zlib-ng-compat"]
default = ["zlib-ng-compat", "mgf", "mzml"]

checksum = ["dep:md5", "dep:sha1", "dep:base16ct"]

mgf = []
mzml = ["dep:quick-xml", "checksum", "dep:memchr", "dep:encoding_rs"]
imzml = ["mzml", "dep:uuid"]

# mzsignal's main functionality requires a linear algebra backend.
# Rust does not support exclusive-or style feature flags.
nalgebra = ["mzsignal", "mzsignal/nalgebra"]
openblas = ["mzsignal", "mzsignal/openblas"]
netlib = ["mzsignal", "mzsignal/netlib"]
intel-mkl = ["mzsignal", "mzsignal/intel-mkl"]

parallelism = ["dep:rayon", "mzsignal?/parallelism"]

# The zlib feature makes the code faster unoptimized, but with LTO the default
# algorithm is faster on tests. Odds are on real data, this will vary with the
# size of the data being shuttled back and forth, and on the quality of the data
# (de)compression.
#
# After substantial testing, zlib-ng-compat is the winner for speed and size on
# a variety of real-world data.
zlib = ["flate2/zlib"]
zlib-ng-compat = ["flate2/zlib-ng-compat"]
zlib-ng = ["flate2/zlib-ng"]
zlib-rs = ["flate2/zlib-rs"]
miniz_oxide = ["flate2/rust_backend"]

# Enables reading mzMLb
mzmlb = ["mzml", "dep:hdf5", "dep:ndarray", "dep:hdf5-sys"]

# Enable compiling and statically linking HDF5, which requires building
# libz-sys in static mode, which conflicts with flate2/zlib-ng-compat
# but not flate2/zlib
hdf5_static = ["mzmlb", "hdf5-sys/static", "hdf5-sys/zlib", "dep:libz-sys"]

thermo = [
    "dep:thermorawfilereader",
    "thermorawfilereader/net8_0",
    "thermorawfilereader/nethost-download",
    "checksum",
]

bruker_tdf = [
    "dep:timsrust",
    "dep:parking_lot",
    "dep:rusqlite",
    "mzsignal",
    "checksum",
]

doc-only = []

serde = [
    "dep:serde",
    "mzpeaks/serde",
    "mzsignal?/serde",
    "chrono/serde",
    "dep:serde_json",
    "dep:serde_with",
]

async = ["async_partial", "tokio/fs"]
async_partial = [
    "dep:tokio",
    "quick-xml/async-tokio",
    "dep:futures",
    "dep:pin-project-lite",
]

proxi = ["dep:reqwest", "serde"]
proxi-async = ["proxi", "dep:futures"]
libloading = ["dep:libloading"]
zstd = ["dep:zstd"]

[dependencies]
regex = "1"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
serde_with = { version = "3.12.0", optional = true }

quick-xml = { version = "0.30", features = ["serialize"], optional = true }
uuid = { version = "1.0", features = ["v4", "serde"], optional = true }
num-traits = "0.2"
log = "0.4.20"
indexmap = { version = "2.0.0", features = ["serde"] }
chrono = "0.4.37"
bitflags = "2.5.0"
identity-hash = "0.1.0"

thiserror = "2.0.2"


mzpeaks = { version = ">=1.0.6,<1.1.0" }

# Internal parallelism
rayon = { version = ">=1.8.0,<2.0", optional = true }

# Internal signal processing
mzsignal = { version = ">=1.1.5,<1.2.0", default-features = false, optional = true, features = [
    'avx',
] }

# Checksums and hashing
sha1 = { version = "0.10.6", optional = true }
md5 = { version = "0.7.0", optional = true }
base16ct = { version = "0.2.0", features = ["alloc"], optional = true }

# Bytes and compression
flate2 = { version = "1.0.20" }
numpress = { version = "1.1.0", optional = true, package = "numpress-rs" }
bytemuck = { version = "1.18.0", features = ["extern_crate_alloc", "min_const_generics"] }
base64-simd = "0.8.0"

# Async reader features
tokio = { version = "1.42", optional = true, features = ["macros"] }

# mzMLb-related features
hdf5 = { version = "0.8.1", optional = true, features = ["blosc", "lzf"] }
hdf5-sys = { version = "0.8.1", optional = true }
libz-sys = { version = "1.1", default-features = false, features = [
    "static",
], optional = true }
ndarray = { version = "0.15.6", optional = true }
filename = { version = "0.1.1", optional = true }

# PROXI-related behaviors
reqwest = { version = "0.12", features = ["json", "blocking"], optional = true }
futures = { version = "0.3", optional = true }

# Thermo RAW-related features
thermorawfilereader = { version = "0.5.5", default-features = false, optional = true }

# Bruker TDF-related features
rusqlite = { version = "0.31.0", optional = true }
timsrust = { version = "0.4.1", default-features = false, features = [
    "tdf",
], optional = true }

parking_lot = { version = "0.12.3", optional = true }
pin-project-lite = { version = "0.2.16", optional = true }
memchr = { version = "2.7.4", optional = true }
libloading = { version = "0.8.6", optional = true }
zstd = { version = "0.13.3", optional = true }
encoding_rs = { version = "0.8.35", optional = true }


[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
test-log = "0.2.12 "
env_logger = "0.11.6"
tempfile = "3.10"
clap = { version = "4.4.11", features = ["derive"] }
tokio = { version = "1.42", features = ["macros", "fs", "rt-multi-thread"] }


[[bench]]
name = "mzml"
harness = false


[package.metadata.docs.rs]
features = [
    "mzml",
    "mgf",
    "parallelism",
    "mzsignal",
    "nalgebra",
    "mzmlb",
    "imzml",
    "async",
    "proxi",
    "proxi-async",
    # "thermo",
    "doc-only",
    "bruker_tdf",
]
no-default-features = true
