You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/de/mod.rs
+18-1
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,13 @@ pub use self::decoder::DecoderImpl;
21
21
22
22
/// Trait that makes a type able to be decoded, akin to serde's `DeserializeOwned` trait.
23
23
///
24
+
/// Some types may require specific contexts. For example, to decode arena-based collections, an arena allocator must be provided as a context. In these cases, the context type `Context` should be specified or bounded.
25
+
///
24
26
/// This trait should be implemented for types which do not have references to data in the reader. For types that contain e.g. `&str` and `&[u8]`, implement [BorrowDecode] instead.
25
27
///
26
28
/// Whenever you implement `Decode` for your type, the base trait `BorrowDecode` is automatically implemented.
27
29
///
28
-
/// This trait will be automatically implemented if you enable the `derive` feature and add `#[derive(bincode::Decode)]` to your type. Note that if the type contains any lifetimes, `BorrowDecode` will be implemented instead.
30
+
/// This trait will be automatically implemented with unbounded `Context` if you enable the `derive` feature and add `#[derive(bincode::Decode)]` to your type. Note that if the type contains any lifetimes, `BorrowDecode` will be implemented instead.
29
31
///
30
32
/// # Implementing this trait manually
31
33
///
@@ -85,6 +87,19 @@ pub use self::decoder::DecoderImpl;
85
87
/// # }
86
88
/// # bincode::impl_borrow_decode!(Foo);
87
89
/// ```
90
+
///
91
+
/// You can use `Context` to require contexts for decoding a type:
0 commit comments