-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c023468
commit 23e8aec
Showing
5 changed files
with
45 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::{error::Result, Cell}; | ||
use std::io::Read; | ||
|
||
/// The `ReadVal` trait defines the contract for reading concrete | ||
/// types from a disk tree. | ||
pub trait ReadVal<R> { | ||
/// The associated type `T` represents the result of | ||
/// deserialization, which may be the deserialized type or an | ||
/// error result, depending on fallibility. | ||
type T; | ||
|
||
/// Reads data from the provided reader and returns the | ||
/// deserialized result. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `rdr` - A `Result` containing a `Cell` and a mutable | ||
/// reference to the reader. | ||
/// | ||
/// # Returns | ||
/// | ||
/// The deserialized result, which can be the deserialized type or | ||
/// an error. | ||
fn read(&self, rdr: Result<(Cell, &mut R)>) -> Self::T; | ||
} | ||
|
||
impl<R, T, F> ReadVal<R> for F | ||
where | ||
R: Read, | ||
F: Fn(Result<(Cell, &mut R)>) -> T, | ||
{ | ||
type T = T; | ||
|
||
fn read(&self, rdr: Result<(Cell, &mut R)>) -> T { | ||
self(rdr) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.