[package]
name = "readcon-core"
version = "0.13.0"
edition = "2024"
rust-version = "1.88"
description = "An oxidized single and multiple CON file reader and writer with FFI bindings for ergonomic C/C++ usage."
repository = "https://github.com/lode-org/readcon-core"
keywords = ["Parser", "comp-chem", "file-format"]
categories = ["filesystem", "parser-implementations", "science"]
license = "MIT"

[lib]
name = "readcon_core"
crate-type = ["lib", "cdylib", "staticlib"]

[features]
# `metatensor` is a Rust crate but its `metatensor-core` dependency pulls
# in a CMake-built C library, so we keep it default-off to keep
# `cargo build` lean for users who only want CON I/O. Enable with
# `--features metatensor` (or pin via the Python wheel build) when you
# need TensorBlock / TensorMap export.
default = []
capi = []
parallel = ["rayon"]
rpc = ["dep:capnp", "dep:capnp-rpc", "dep:capnpc", "dep:tokio", "dep:tokio-util", "dep:futures"]
# NB: dlpk/pyo3 is intentionally NOT activated -- dlpk v0.1.5 pins
# pyo3 = "0.26" but readcon-core's python.rs is on pyo3 0.28, and
# pyo3-ffi is `links = "python"` so the two cannot coexist in the
# graph. v0.11 builds its own __dlpack__ PyCapsule wrapper using
# dlpk's sys::DLManagedTensorVersioned types directly. Once dlpk
# bumps to pyo3 0.28 (upstream), flip this to `dlpk/pyo3`.
python = ["dep:pyo3", "dep:numpy"]
zstd = ["dep:zstd"]
metatensor = ["dep:metatensor"]
# Multi-format trajectory import via the chemfiles C++ library (Rust
# bindings). Off by default so lean builds / conda C-only consumers do
# not pull libchemfiles. Enable with `--features chemfiles`.
chemfiles = ["dep:chemfiles"]

[dependencies]
# v0.11 storage abstraction. The `Array` trait + DLPack export pattern
# mirrors metatensor v2's `Box<dyn Array>` storage hook so that
# downstream consumers (eOn, GROMACS, ML potentials in PyTorch/JAX/TF)
# get zero-copy interop without each language reimplementing a
# bespoke pointer surface. dlpk is hard-deppy because the C-ABI
# DLPack export is the v0.11 surface; the `ndarray` and `pyo3`
# features are turned on conditionally below.
dlpk = { version = "0.1.5", features = ["ndarray"] }
ndarray = "0.17"
fast-float2 = "0.2"
flate2 = "1"
serde_json = "1"
memchr = "2"
memmap2 = "0.9"
rustc-hash = "2"
rayon = { version = "1.10", optional = true }
capnp = { version = "0.20", optional = true }
capnp-rpc = { version = "0.20", optional = true }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "net", "macros"], optional = true }
tokio-util = { version = "0.7", features = ["compat"], optional = true }
futures = { version = "0.3", optional = true }
pyo3 = { version = "0.28", features = ["extension-module"], optional = true }
numpy = { version = "0.28", optional = true }
metatensor = { version = "0.3.0-rc2", optional = true }
zstd = { version = "0.13", optional = true }
chemfiles = { version = "0.10", optional = true }

[dev-dependencies]
cog = "0.1.0"
criterion = { version = "0.6.0", features = ["html_reports"] }
tempfile = "3"

[[example]]
name = "rust_usage"

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

[build-dependencies]
capnpc = { version = "0.20", optional = true }

[package.metadata.capi]
min_version = "0.10.17"

[package.metadata.capi.header]
name = "readcon-core"
subdirectory = ""
generation = false

[package.metadata.capi.pkg_config]
name = "readcon-core"
filename = "readcon-core"
description = "CON/convel file reader and writer with FFI, Python, Julia bindings"

[package.metadata.capi.install.include]
asset = [
    { from = "include/readcon-core.h" },
    { from = "include/readcon-core.hpp" },
]

[profile.release]
lto = "thin"
codegen-units = 1

# The profile that 'dist' / cargo-c builds use for shipping binaries.
[profile.dist]
inherits = "release"
lto = "fat"
strip = "symbols"
