Skip to content

Commit

Permalink
make index feature experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
Quba1 committed Feb 3, 2024
1 parent 7275212 commit 58d92ac
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/rust-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
cargo clean
- name: Test with cargo
run: |
RUST_BACKTRACE=full cargo test --features "ec_index"
RUST_BACKTRACE=full cargo test --features "experimental_index"
- name: Check with clippy
run: |
cargo clippy --features "ec_index"
cargo clippy --features "experimental_index"
- name: Build release
run: |
cargo build --release --features "ec_index"
cargo build --release --features "experimental_index"
build-macos:

Expand All @@ -45,10 +45,10 @@ jobs:
cargo clean
- name: Test with cargo
run: |
RUST_BACKTRACE=full cargo test --features "ec_index"
RUST_BACKTRACE=full cargo test --features "experimental_index"
- name: Check with clippy
run: |
cargo clippy --features "ec_index"
cargo clippy --features "experimental_index"
- name: Build release
run: |
cargo build --release --features "ec_index"
cargo build --release --features "experimental_index"
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
cargo clean
- name: Build with cargo
run: |
cargo build --release --features "ec_index"
cargo build --release --features "experimental_index"
cargo clean
- name: Test with cargo
run: |
cargo test --features "ec_index"
cargo test --features "experimental_index"
cargo clean
- name: Benchmark with criterion
run: |
Expand All @@ -53,11 +53,11 @@ jobs:
cargo clean
- name: Build with cargo
run: |
cargo build --release --features "ec_index"
cargo build --release --features "experimental_index"
cargo clean
- name: Test with cargo
run: |
cargo test --features "ec_index"
cargo test --features "experimental_index"
cargo clean
- name: Benchmark with criterion
run: |
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ rand = "0.8"
anyhow = "1.0"

[features]
default = ["ec_index"]
docs = ["eccodes-sys/docs"]
ec_index = []
experimental_index = []

[package.metadata.docs.rs]
features = ["docs", "ec_index"]
features = ["docs", "experimental_index"]

[[bench]]
name = "main"
Expand Down
4 changes: 2 additions & 2 deletions src/codes_handle/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
errors::CodesError,
intermediate_bindings::{codes_handle_delete, codes_handle_new_from_file},
};
#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
use crate::{intermediate_bindings::codes_index::codes_handle_new_from_index, CodesIndex};

use super::GribFile;
Expand Down Expand Up @@ -117,7 +117,7 @@ impl FallibleStreamingIterator for CodesHandle<GribFile> {
}
}

#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
impl FallibleStreamingIterator for CodesHandle<CodesIndex> {
type Item = KeyedMessage;

Expand Down
16 changes: 8 additions & 8 deletions src/codes_handle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//!Main crate module containing definition of `CodesHandle`
//!and all associated functions and data structures

use crate::errors::CodesError;
#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
use crate::{codes_index::CodesIndex, intermediate_bindings::codes_index::codes_index_delete};
use crate::CodesError;
use bytes::Bytes;
use eccodes_sys::{codes_handle, codes_keys_iterator, codes_nearest, ProductKind_PRODUCT_GRIB};
use errno::errno;
Expand Down Expand Up @@ -118,7 +118,7 @@ pub enum KeysIteratorFlags {
enum DataContainer {
FileBytes(Bytes),
FileBuffer(File),
#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
Empty(),
}

Expand Down Expand Up @@ -266,8 +266,8 @@ impl CodesHandle<GribFile> {
}
}

#[cfg(feature = "ec_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg(feature = "experimental_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
impl CodesHandle<CodesIndex> {
pub fn new_from_index(
index: CodesIndex,
Expand Down Expand Up @@ -358,7 +358,7 @@ impl SpecialDrop for GribFile {
}
}

#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
impl SpecialDrop for CodesIndex {
fn spec_drop(&mut self) {
unsafe {
Expand Down Expand Up @@ -390,7 +390,7 @@ mod tests {
use eccodes_sys::ProductKind_PRODUCT_GRIB;

use crate::codes_handle::{CodesHandle, DataContainer, ProductKind};
#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
use crate::codes_index::{CodesIndex, Select};
use log::Level;
use std::path::Path;
Expand Down Expand Up @@ -438,7 +438,7 @@ mod tests {
}

#[test]
#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
fn index_constructor_and_destructor() {
let file_path = Path::new("./data/iceland-surface.idx");
let index = CodesIndex::read_from_file(file_path)
Expand Down
8 changes: 4 additions & 4 deletions src/codes_index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use eccodes_sys::codes_index;
use std::path::Path;

#[derive(Debug)]
#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub struct CodesIndex {
pub(crate) pointer: *mut codes_index,
}
Expand All @@ -22,7 +22,7 @@ pub trait Select<T> {
}

impl CodesIndex {
#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub fn new_from_keys(keys: &[&str]) -> Result<CodesIndex, CodesError> {
let keys = keys.join(",");

Expand All @@ -38,7 +38,7 @@ impl CodesIndex {
})
}

#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub fn read_from_file(index_file_path: &Path) -> Result<CodesIndex, CodesError> {
let file_path = index_file_path.to_str().ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "Path is not valid utf8")
Expand All @@ -54,7 +54,7 @@ impl CodesIndex {
})
}

#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub fn add_grib_file(self, index_file_path: &Path) -> Result<CodesIndex, CodesError> {
let file_path = index_file_path.to_str().ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "Path is not valid utf8")
Expand Down
2 changes: 1 addition & 1 deletion src/intermediate_bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//!to make ecCodes usage safer and easier,
//!but they are unsafe as they operate on raw `codes_handle`.

#[cfg(feature = "ec_index")]
#[cfg(feature = "experimental_index")]
pub mod codes_index;

use std::{
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@
//!

pub mod codes_handle;
#[cfg(feature = "ec_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg(feature = "experimental_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub mod codes_index;
pub mod errors;
mod intermediate_bindings;

pub use codes_handle::{
CodesHandle, Key, KeyType, KeyedMessage, KeysIteratorFlags, NearestGridpoint, ProductKind,
};
#[cfg(feature = "ec_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "ec_index")))]
#[cfg(feature = "experimental_index")]
#[cfg_attr(docsrs, doc(cfg(feature = "experimental_index")))]
pub use codes_index::CodesIndex;
pub use errors::CodesError;
pub use fallible_iterator::{FallibleIterator, IntoFallibleIterator};
Expand Down
2 changes: 1 addition & 1 deletion tests/index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "ec_index")]
#![cfg(feature = "experimental_index")]

use std::{path::Path, thread};

Expand Down

0 comments on commit 58d92ac

Please sign in to comment.