Skip to content

Commit

Permalink
💀 SolidEntries trait make deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 18, 2023
1 parent a89ce0a commit 206e691
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/src/archive/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub trait Entry: SealedIntoChunks {
}

/// Solid mode entries block.
#[deprecated(since = "0.4.0")]
pub trait SolidEntries: SealedIntoChunks {
fn bytes_len(&self) -> usize;
fn into_bytes(self) -> Vec<u8>;
Expand All @@ -54,13 +55,15 @@ impl SealedIntoChunks for EntryContainer {

impl Entry for EntryContainer {
fn bytes_len(&self) -> usize {
#[allow(deprecated)]
match self {
Self::Regular(r) => r.bytes_len(),
Self::Solid(s) => s.bytes_len(),
}
}

fn into_bytes(self) -> Vec<u8> {
#[allow(deprecated)]
match self {
Self::Regular(r) => r.into_bytes(),
Self::Solid(s) => s.into_bytes(),
Expand Down Expand Up @@ -184,6 +187,7 @@ impl SealedIntoChunks for SolidReadEntry {
}
}

#[allow(deprecated)]
impl SolidEntries for SolidReadEntry {
fn bytes_len(&self) -> usize {
self.clone().into_bytes().len()
Expand Down Expand Up @@ -543,6 +547,7 @@ impl SealedIntoChunks for ChunkSolidEntries {
}
}

#[allow(deprecated)]
impl SolidEntries for ChunkSolidEntries {
fn bytes_len(&self) -> usize {
self.0.iter().map(|chunk| chunk.bytes_len()).sum()
Expand Down
6 changes: 5 additions & 1 deletion lib/src/archive/entry/builder.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#[allow(deprecated)]
use crate::archive::SolidEntries;
use crate::{
archive::entry::{
writer_and_hash, Entry, EntryContainer, EntryHeader, EntryName, EntryReference, Metadata,
Permission, RegularEntry, SolidEntries, SolidHeader, SolidReadEntry, WriteOption,
Permission, RegularEntry, SolidHeader, SolidReadEntry, WriteOption,
},
cipher::CipherWriter,
compress::CompressionWriter,
io::TryIntoInner,
};

use std::{
io::{self, Write},
time::Duration,
Expand Down Expand Up @@ -303,6 +306,7 @@ impl SolidEntriesBuilder {
/// }
/// ```
#[deprecated(since = "0.3.3", note = "Use `SolidEntryBuilder::build` instead.")]
#[allow(deprecated)]
#[inline]
pub fn build(self) -> io::Result<impl SolidEntries> {
self.0.build_as_entry()
Expand Down
5 changes: 4 additions & 1 deletion lib/src/archive/write.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[allow(deprecated)]
use crate::archive::SolidEntries;
use crate::{
archive::{Archive, ArchiveHeader, Entry, EntryPart, SolidEntries, PNA_HEADER},
archive::{Archive, ArchiveHeader, Entry, EntryPart, PNA_HEADER},
chunk::{ChunkType, ChunkWriter},
};
use std::io::{self, Write};
Expand Down Expand Up @@ -85,6 +87,7 @@ impl<W: Write> Archive<W> {
/// }
/// ```
#[deprecated(since = "0.3.3", note = "Use `Archive::add_entry` instead.")]
#[allow(deprecated)]
pub fn add_solid_entries(&mut self, entries: impl SolidEntries) -> io::Result<usize> {
let bytes = entries.into_bytes();
self.inner.write_all(&bytes)?;
Expand Down

0 comments on commit 206e691

Please sign in to comment.