Skip to main content

rspack_cacheable/
lib.rs

1#[cfg(feature = "noop")]
2pub use rspack_cacheable_macros::{
3  disable_cacheable as cacheable, disable_cacheable_dyn as cacheable_dyn,
4};
5pub use rspack_cacheable_macros::{
6  disable_cacheable, disable_cacheable_dyn, enable_cacheable, enable_cacheable_dyn,
7};
8#[cfg(not(feature = "noop"))]
9pub use rspack_cacheable_macros::{
10  enable_cacheable as cacheable, enable_cacheable_dyn as cacheable_dyn,
11};
12pub mod r#dyn;
13pub mod utils;
14pub mod with;
15
16mod context;
17mod deserialize;
18mod error;
19mod serialize;
20
21#[doc(hidden)]
22pub mod __private {
23  #[doc(hidden)]
24  pub extern crate inventory;
25  #[doc(hidden)]
26  pub extern crate rkyv;
27}
28
29#[cfg(not(feature = "noop"))]
30pub use deserialize::from_bytes;
31#[cfg(feature = "noop")]
32pub fn from_bytes<T, C: CacheableContext>(_bytes: &[u8], _context: &C) -> Result<T> {
33  let _ = deserialize::from_bytes::<u8, C>;
34  panic!("Cannot use from_bytes when noop feature is enabled")
35}
36
37#[cfg(not(feature = "noop"))]
38pub use serialize::to_bytes;
39#[cfg(feature = "noop")]
40pub fn to_bytes<T, C: CacheableContext>(_value: &T, _ctx: &C) -> Result<Vec<u8>> {
41  let _ = serialize::to_bytes::<u8, C>;
42  panic!("Cannot use to_bytes when noop feature is enabled")
43}
44
45pub use context::{CacheableContext, ContextGuard};
46pub use deserialize::{Deserializer, Validator};
47pub use error::{Error, Result};
48pub use serialize::Serializer;
49pub use xxhash_rust;