Skip to content

Commit 3cb4704

Browse files
committed
feat: variant feature flag
1 parent b363f00 commit 3cb4704

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ quinn_endpoint_setup = ["rpc", "dep:rustls", "dep:rcgen", "dep:anyhow", "dep:fut
6868
spans = ["dep:tracing"]
6969
stream = ["dep:futures-util"]
7070
derive = ["dep:irpc-derive"]
71+
varint-util = ["dep:postcard", "dep:smallvec", "tokio/io-util"]
7172
default = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"]
7273

7374
[[example]]

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,7 @@ use serde::{de::DeserializeOwned, Serialize};
175175

176176
use self::channel::none::NoReceiver;
177177

178-
#[cfg(feature = "rpc")]
179-
#[cfg_attr(quicrpc_docsrs, doc(cfg(feature = "rpc")))]
180178
pub mod util;
181-
#[cfg(not(feature = "rpc"))]
182-
mod util;
183179

184180
/// Requirements for a RPC message
185181
///
@@ -1172,6 +1168,10 @@ pub enum RequestError {
11721168
#[cfg_attr(quicrpc_docsrs, doc(cfg(feature = "rpc")))]
11731169
#[error("error opening stream: {0}")]
11741170
Other(#[from] anyhow::Error),
1171+
1172+
#[cfg(not(feature = "rpc"))]
1173+
#[error("(Without the rpc feature, requests cannot fail")]
1174+
Unreachable,
11751175
}
11761176

11771177
/// Error type that subsumes all possible errors in this crate, for convenience.
@@ -1212,6 +1212,8 @@ impl From<RequestError> for io::Error {
12121212
RequestError::Connection(e) => e.into(),
12131213
#[cfg(feature = "rpc")]
12141214
RequestError::Other(e) => io::Error::other(e),
1215+
#[cfg(not(feature = "rpc"))]
1216+
RequestError::Unreachable => unreachable!(),
12151217
}
12161218
}
12171219
}

src/util.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ mod quinn_setup_utils {
167167
#[cfg_attr(quicrpc_docsrs, doc(cfg(feature = "quinn_endpoint_setup")))]
168168
pub use quinn_setup_utils::*;
169169

170-
#[cfg(feature = "rpc")]
170+
#[cfg(any(feature = "rpc", feature = "varint-util"))]
171171
mod varint_util {
172172
use std::{
173173
future::Future,
@@ -375,7 +375,8 @@ mod varint_util {
375375
}
376376
}
377377
}
378-
#[cfg(feature = "rpc")]
378+
379+
#[cfg(any(feature = "rpc", feature = "varint-util"))]
379380
pub use varint_util::{AsyncReadVarintExt, AsyncWriteVarintExt, WriteVarintExt};
380381

381382
mod fuse_wrapper {

0 commit comments

Comments
 (0)