mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-01-07 09:48:45 +00:00
io: Impl Truncate
/Length
for refs
This commit is contained in:
parent
f17bac49b3
commit
120b5f52cb
2 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Truncate**: `impl<T: Truncate> Truncate for &mut T` ([PR](https://github.com/Serial-ATA/lofty-rs/pull/384))
|
||||||
|
- **Length**: `impl<T: Length> Truncate for &T` ([PR](https://github.com/Serial-ATA/lofty-rs/pull/384))
|
||||||
|
|
||||||
## [0.19.0] - 2024-04-21
|
## [0.19.0] - 2024-04-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -89,6 +89,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Truncate for &mut T
|
||||||
|
where
|
||||||
|
T: Truncate,
|
||||||
|
{
|
||||||
|
type Error = <T as Truncate>::Error;
|
||||||
|
|
||||||
|
fn truncate(&mut self, new_len: u64) -> Result<(), Self::Error> {
|
||||||
|
(**self).truncate(new_len)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Provides a method to get the length of a storage object
|
/// Provides a method to get the length of a storage object
|
||||||
///
|
///
|
||||||
/// This is one component of the [`FileLike`] trait, which is used to provide implementors access to any
|
/// This is one component of the [`FileLike`] trait, which is used to provide implementors access to any
|
||||||
|
@ -154,6 +165,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Length for &T
|
||||||
|
where
|
||||||
|
T: Length,
|
||||||
|
{
|
||||||
|
type Error = <T as Length>::Error;
|
||||||
|
|
||||||
|
fn len(&self) -> Result<u64, Self::Error> {
|
||||||
|
Length::len(*self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Provides a set of methods to read and write to a file-like object
|
/// Provides a set of methods to read and write to a file-like object
|
||||||
///
|
///
|
||||||
/// This is a combination of the [`Read`], [`Write`], [`Seek`], [`Truncate`], and [`Length`] traits.
|
/// This is a combination of the [`Read`], [`Write`], [`Seek`], [`Truncate`], and [`Length`] traits.
|
||||||
|
|
Loading…
Reference in a new issue