Skip to content

Commit

Permalink
Fixed build with bitround or zfp features without async feature
Browse files Browse the repository at this point in the history
Also cleanup some redundant `#[cfg_attr(feature = "async", ...]`
  • Loading branch information
LDeakin committed Jan 29, 2024
1 parent e87df30 commit f2cbd9f
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fixed build with `bitround` or `zfp` features without `async` feature

## [0.11.0] - 2024-01-26

### Highlights
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zarrs"
version = "0.11.0"
version = "0.11.1"
authors = ["Lachlan Deakin <ljdgit@gmail.com>"]
edition = "2021"
rust-version = "1.71"
Expand Down
6 changes: 3 additions & 3 deletions src/array/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub trait BytesPartialDecoderTraits: Send + Sync {

#[cfg(feature = "async")]
/// Asynchronous partial bytes decoder traits.
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
pub trait AsyncBytesPartialDecoderTraits: Send + Sync {
/// Partially decode bytes with optional parallelism.
///
Expand Down Expand Up @@ -424,7 +424,7 @@ pub trait ArrayPartialDecoderTraits: Send + Sync {

#[cfg(feature = "async")]
/// Asynchronous partial array decoder traits.
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
pub trait AsyncArrayPartialDecoderTraits: Send + Sync {
/// Partially decode an array.
///
Expand Down Expand Up @@ -507,7 +507,7 @@ impl<'a> AsyncStoragePartialDecoder<'a> {
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl AsyncBytesPartialDecoderTraits for AsyncStoragePartialDecoder<'_> {
async fn partial_decode_opt(
&self,
Expand Down
8 changes: 6 additions & 2 deletions src/array/codec/array_to_array/bitround/bitround_codec.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use crate::{
array::{
codec::{
ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToArrayCodecTraits,
AsyncArrayPartialDecoderTraits, CodecError, CodecTraits,
ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToArrayCodecTraits, CodecError,
CodecTraits,
},
ChunkRepresentation, DataType,
},
metadata::Metadata,
};

#[cfg(feature = "async")]
use crate::array::codec::AsyncArrayPartialDecoderTraits;

use super::{bitround_partial_decoder, round_bytes, BitroundCodecConfiguration, IDENTIFIER};

/// A `bitround` codec implementation.
Expand Down Expand Up @@ -98,6 +101,7 @@ impl ArrayToArrayCodecTraits for BitroundCodec {
))
}

#[cfg(feature = "async")]
async fn async_partial_decoder_opt<'a>(
&'a self,
input_handle: Box<dyn AsyncArrayPartialDecoderTraits + 'a>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use crate::{
array::{
codec::{ArrayPartialDecoderTraits, AsyncArrayPartialDecoderTraits, CodecError},
codec::{ArrayPartialDecoderTraits, CodecError},
DataType,
},
array_subset::ArraySubset,
};

#[cfg(feature = "async")]
use crate::array::codec::AsyncArrayPartialDecoderTraits;

use super::{round_bytes, IDENTIFIER};

/// Partial decoder for the `bitround` codec.
Expand Down Expand Up @@ -65,13 +68,15 @@ impl ArrayPartialDecoderTraits for BitroundPartialDecoder<'_> {
}
}

#[cfg(feature = "async")]
/// Asynchronous partial decoder for the `bitround` codec.
pub struct AsyncBitroundPartialDecoder<'a> {
input_handle: Box<dyn AsyncArrayPartialDecoderTraits + 'a>,
data_type: DataType,
keepbits: u32,
}

#[cfg(feature = "async")]
impl<'a> AsyncBitroundPartialDecoder<'a> {
/// Create a new partial decoder for the `bitround` codec.
pub fn new(
Expand Down Expand Up @@ -104,7 +109,8 @@ impl<'a> AsyncBitroundPartialDecoder<'a> {
}
}

#[cfg_attr(feature = "async", async_trait::async_trait)]
#[cfg(feature = "async")]
#[async_trait::async_trait]
impl AsyncArrayPartialDecoderTraits for AsyncBitroundPartialDecoder<'_> {
async fn partial_decode_opt(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a> AsyncBytesPartialDecoder<'a> {
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl AsyncArrayPartialDecoderTraits for AsyncBytesPartialDecoder<'_> {
async fn partial_decode_opt(
&self,
Expand Down
5 changes: 4 additions & 1 deletion src/array/codec/array_to_bytes/zfp/zfp_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
array::{
codec::{
ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits,
AsyncArrayPartialDecoderTraits, AsyncBytesPartialDecoderTraits,
BytesPartialDecoderTraits, Codec, CodecError, CodecPlugin, CodecTraits,
},
BytesRepresentation, ChunkRepresentation, DataType,
Expand All @@ -16,6 +15,9 @@ use crate::{
plugin::{PluginCreateError, PluginMetadataInvalidError},
};

#[cfg(feature = "async")]
use crate::array::codec::{AsyncArrayPartialDecoderTraits, AsyncBytesPartialDecoderTraits};

use super::{
zarr_data_type_to_zfp_data_type,
zfp_bitstream::ZfpBitstream,
Expand Down Expand Up @@ -233,6 +235,7 @@ impl ArrayToBytesCodecTraits for ZfpCodec {
)?))
}

#[cfg(feature = "async")]
async fn async_partial_decoder_opt<'a>(
&'a self,
input_handle: Box<dyn AsyncBytesPartialDecoderTraits + 'a>,
Expand Down
13 changes: 8 additions & 5 deletions src/array/codec/array_to_bytes/zfp/zfp_partial_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use zfp_sys::zfp_type;
use crate::{
array::{
chunk_shape_to_array_shape,
codec::{
ArrayPartialDecoderTraits, AsyncArrayPartialDecoderTraits,
AsyncBytesPartialDecoderTraits, BytesPartialDecoderTraits, CodecError,
},
codec::{ArrayPartialDecoderTraits, BytesPartialDecoderTraits, CodecError},
ChunkRepresentation,
},
array_subset::ArraySubset,
byte_range::extract_byte_ranges,
};

#[cfg(feature = "async")]
use crate::array::codec::{AsyncArrayPartialDecoderTraits, AsyncBytesPartialDecoderTraits};

use super::{zarr_data_type_to_zfp_data_type, zfp_decode, ZfpMode};

/// Partial decoder for the `zfp` codec.
Expand Down Expand Up @@ -92,6 +92,7 @@ impl ArrayPartialDecoderTraits for ZfpPartialDecoder<'_> {
}
}

#[cfg(feature = "async")]
/// Asynchronous partial decoder for the `zfp` codec.
pub struct AsyncZfpPartialDecoder<'a> {
input_handle: Box<dyn AsyncBytesPartialDecoderTraits + 'a>,
Expand All @@ -100,6 +101,7 @@ pub struct AsyncZfpPartialDecoder<'a> {
zfp_type: zfp_type,
}

#[cfg(feature = "async")]
impl<'a> AsyncZfpPartialDecoder<'a> {
/// Create a new partial decoder for the `zfp` codec.
pub fn new(
Expand All @@ -125,7 +127,8 @@ impl<'a> AsyncZfpPartialDecoder<'a> {
}
}

#[cfg_attr(feature = "async", async_trait::async_trait)]
#[cfg(feature = "async")]
#[async_trait::async_trait]
impl AsyncArrayPartialDecoderTraits for AsyncZfpPartialDecoder<'_> {
async fn partial_decode_opt(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/array/codec/byte_interval_partial_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'a> AsyncByteIntervalPartialDecoder<'a> {
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<'a> AsyncBytesPartialDecoderTraits for AsyncByteIntervalPartialDecoder<'a> {
async fn partial_decode_opt(
&self,
Expand Down
4 changes: 2 additions & 2 deletions src/array/codec/partial_decoder_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl BytesPartialDecoderTraits for BytesPartialDecoderCache<'_> {
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl AsyncBytesPartialDecoderTraits for BytesPartialDecoderCache<'_> {
async fn partial_decode_opt(
&self,
Expand Down Expand Up @@ -165,7 +165,7 @@ impl<'a> ArrayPartialDecoderTraits for ArrayPartialDecoderCache<'a> {
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<'a> AsyncArrayPartialDecoderTraits for ArrayPartialDecoderCache<'a> {
async fn partial_decode_opt(
&self,
Expand Down
8 changes: 4 additions & 4 deletions src/storage/storage_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<TStorage: ?Sized + ReadableWritableStorageTraits> ReadableWritableStorageTr
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
for StorageHandle<'_, TStorage>
{
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
for StorageHandle<'_, TStorage>
{
Expand All @@ -178,7 +178,7 @@ impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
for StorageHandle<'_, TStorage>
{
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableWritableStorageTraits> AsyncReadableWritableStorageTraits
for StorageHandle<'_, TStorage>
{
Expand Down
8 changes: 4 additions & 4 deletions src/storage/storage_transformer/performance_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl<TStorage: ?Sized + ReadableWritableStorageTraits> ReadableWritableStorageTr
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
for PerformanceMetricsStorageTransformerImpl<'_, TStorage>
{
Expand Down Expand Up @@ -365,7 +365,7 @@ impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
for PerformanceMetricsStorageTransformerImpl<'_, TStorage>
{
Expand All @@ -383,7 +383,7 @@ impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
for PerformanceMetricsStorageTransformerImpl<'_, TStorage>
{
Expand Down Expand Up @@ -426,7 +426,7 @@ impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableWritableStorageTraits> AsyncReadableWritableStorageTraits
for PerformanceMetricsStorageTransformerImpl<'_, TStorage>
{
Expand Down
8 changes: 4 additions & 4 deletions src/storage/storage_transformer/usage_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl<TStorage: ?Sized + ReadableWritableStorageTraits> ReadableWritableStorageTr
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
for UsageLogStorageTransformerImpl<TStorage>
{
Expand Down Expand Up @@ -461,7 +461,7 @@ impl<TStorage: ?Sized + AsyncReadableStorageTraits> AsyncReadableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
for UsageLogStorageTransformerImpl<TStorage>
{
Expand Down Expand Up @@ -509,7 +509,7 @@ impl<TStorage: ?Sized + AsyncListableStorageTraits> AsyncListableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
for UsageLogStorageTransformerImpl<TStorage>
{
Expand Down Expand Up @@ -570,7 +570,7 @@ impl<TStorage: ?Sized + AsyncWritableStorageTraits> AsyncWritableStorageTraits
}

#[cfg(feature = "async")]
#[cfg_attr(feature = "async", async_trait::async_trait)]
#[async_trait::async_trait]
impl<TStorage: ?Sized + AsyncReadableWritableStorageTraits> AsyncReadableWritableStorageTraits
for UsageLogStorageTransformerImpl<TStorage>
{
Expand Down

0 comments on commit f2cbd9f

Please sign in to comment.