1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Key and value transforms for cache tiers.
//!
//! Transforms allow a cache to store data in a different representation than
//! the types exposed to callers. A common example is serialization: the caller
//! works with typed values while the backing tier stores raw bytes.
//!
//! # Core Traits
//!
//! | Trait | Direction | Use |
//! |-------|-----------|-----|
//! | [`Encoder<A, B>`] | `A → B` | One-way key encoding |
//! | [`Codec<A, B>`] | `A ↔ B` | Bidirectional value encoding/decoding |
//!
//! # Decode Outcomes
//!
//! [`Codec::decode`] returns [`DecodeOutcome<T>`] rather than a plain value:
//!
//! - [`DecodeOutcome::Value(v)`](DecodeOutcome::Value) - decoded successfully.
//! - [`DecodeOutcome::SoftFailure(reason)`](DecodeOutcome::SoftFailure) - the stored data is
//! undecodable (e.g., format version mismatch, corrupt bytes) and should be treated as a
//! cache miss rather than a hard error.
//!
//! # Implementations
//!
//! | Type | Description |
//! |------|-------------|
//! | [`TransformEncoder`] | Wraps a closure as an [`Encoder`]. |
//! | [`TransformCodec`] | Wraps a pair of closures as a [`Codec`]. Decode always returns [`DecodeOutcome::Value`] — closures that need soft-failure semantics should implement [`Codec`] directly. |
//!
//! # Helpers
//!
//! [`infallible`] and [`infallible_owned`] wrap closures that cannot fail so
//! they can be used where a fallible closure is expected.
pub
pub use ;
pub use TransformAdapter;