diff --git a/cli/benches/list.rs b/cli/benches/list.rs index ad44f219..feda95e2 100644 --- a/cli/benches/list.rs +++ b/cli/benches/list.rs @@ -6,7 +6,7 @@ use portable_network_archive::{cli, command}; use test::Bencher; #[bench] -fn regular(b: &mut Bencher) { +fn normal(b: &mut Bencher) { b.iter(|| { command::entry(cli::Cli::parse_from([ "pna", diff --git a/cli/src/command/chmod.rs b/cli/src/command/chmod.rs index c91a40e2..e68a7321 100644 --- a/cli/src/command/chmod.rs +++ b/cli/src/command/chmod.rs @@ -8,7 +8,7 @@ use crate::{ utils::{GlobPatterns, PathPartExt}, }; use clap::{Parser, ValueHint}; -use pna::RegularEntry; +use pna::NormalEntry; use std::{ io, path::PathBuf, @@ -75,7 +75,7 @@ fn archive_chmod(args: ChmodCommand) -> io::Result<()> { } #[inline] -fn transform_entry(entry: RegularEntry, mode: Mode) -> RegularEntry { +fn transform_entry(entry: NormalEntry, mode: Mode) -> NormalEntry { let metadata = entry.metadata().clone(); let permission = metadata.permission().map(|p| { let mode = mode.apply_to(p.permissions()); diff --git a/cli/src/command/chown.rs b/cli/src/command/chown.rs index 63d7a137..958b6071 100644 --- a/cli/src/command/chown.rs +++ b/cli/src/command/chown.rs @@ -10,7 +10,7 @@ use crate::{ utils::{GlobPatterns, PathPartExt}, }; use clap::{Parser, ValueHint}; -use pna::RegularEntry; +use pna::NormalEntry; use std::ops::Not; use std::{io, path::PathBuf, str::FromStr}; @@ -74,7 +74,7 @@ fn archive_chown(args: ChownCommand) -> io::Result<()> { } #[inline] -fn transform_entry(entry: RegularEntry, owner: &Owner) -> RegularEntry { +fn transform_entry(entry: NormalEntry, owner: &Owner) -> NormalEntry { let metadata = entry.metadata().clone(); let permission = metadata.permission().map(|p| { let user = owner.user(); diff --git a/cli/src/command/commons.rs b/cli/src/command/commons.rs index bc80a543..3e5e1335 100644 --- a/cli/src/command/commons.rs +++ b/cli/src/command/commons.rs @@ -4,8 +4,8 @@ use crate::{ }; use normalize_path::*; use pna::{ - prelude::*, Archive, EntryBuilder, EntryName, EntryPart, EntryReference, ReadEntry, - RegularEntry, SolidEntryBuilder, WriteOptions, MIN_CHUNK_BYTES_SIZE, PNA_HEADER, + prelude::*, Archive, EntryBuilder, EntryName, EntryPart, EntryReference, NormalEntry, + ReadEntry, SolidEntryBuilder, WriteOptions, MIN_CHUNK_BYTES_SIZE, PNA_HEADER, }; use std::{ env::temp_dir, @@ -115,7 +115,7 @@ pub(crate) fn create_entry( keep_options, owner_options, }: CreateOptions, -) -> io::Result { +) -> io::Result { if path.is_symlink() { let source = fs::read_link(path)?; let entry = EntryBuilder::new_symbolic_link( @@ -363,9 +363,9 @@ pub(crate) trait TransformStrategy { where W: Write, T: AsRef<[u8]>, - F: FnMut(io::Result>) -> io::Result>>, - RegularEntry: From, - RegularEntry: Entry; + F: FnMut(io::Result>) -> io::Result>>, + NormalEntry: From, + NormalEntry: Entry; } pub(crate) struct TransformStrategyUnSolid; @@ -380,9 +380,9 @@ impl TransformStrategy for TransformStrategyUnSolid { where W: Write, T: AsRef<[u8]>, - F: FnMut(io::Result>) -> io::Result>>, - RegularEntry: From, - RegularEntry: Entry, + F: FnMut(io::Result>) -> io::Result>>, + NormalEntry: From, + NormalEntry: Entry, { match read_entry? { ReadEntry::Solid(s) => { @@ -393,7 +393,7 @@ impl TransformStrategy for TransformStrategyUnSolid { } Ok(()) } - ReadEntry::Regular(n) => { + ReadEntry::Normal(n) => { if let Some(entry) = transformer(Ok(n))? { archive.add_entry(entry)?; } @@ -415,9 +415,9 @@ impl TransformStrategy for TransformStrategyKeepSolid { where W: Write, T: AsRef<[u8]>, - F: FnMut(io::Result>) -> io::Result>>, - RegularEntry: From, - RegularEntry: Entry, + F: FnMut(io::Result>) -> io::Result>>, + NormalEntry: From, + NormalEntry: Entry, { match read_entry? { ReadEntry::Solid(s) => { @@ -438,7 +438,7 @@ impl TransformStrategy for TransformStrategyKeepSolid { archive.add_entry(builder.build()?)?; Ok(()) } - ReadEntry::Regular(n) => { + ReadEntry::Normal(n) => { if let Some(entry) = transformer(Ok(n))? { archive.add_entry(entry)?; } @@ -478,7 +478,7 @@ pub(crate) fn run_process_archive<'p, Provider, F>( ) -> io::Result<()> where Provider: FnMut() -> Option<&'p str>, - F: FnMut(io::Result) -> io::Result<()>, + F: FnMut(io::Result) -> io::Result<()>, { let password = password_provider(); run_read_entries(archive_provider, |entry| match entry? { @@ -488,7 +488,7 @@ where } Ok(()) } - ReadEntry::Regular(regular) => processor(Ok(regular)), + ReadEntry::Normal(regular) => processor(Ok(regular)), }) } @@ -550,7 +550,7 @@ pub(crate) fn run_entries<'p, P, Provider, F>( where P: AsRef, Provider: FnMut() -> Option<&'p str>, - F: FnMut(io::Result>>) -> io::Result<()>, + F: FnMut(io::Result>>) -> io::Result<()>, { let password = password_provider(); run_read_entries_mem(path, |entry| { @@ -560,7 +560,7 @@ where processor(r.map(Into::into))?; } } - ReadEntry::Regular(r) => processor(Ok(r))?, + ReadEntry::Normal(r) => processor(Ok(r))?, } Ok(()) }) @@ -579,8 +579,8 @@ where P: AsRef, Provider: FnMut() -> Option<&'p str>, F: FnMut( - io::Result>>, - ) -> io::Result>>>, + io::Result>>, + ) -> io::Result>>>, Transform: TransformStrategy, { let password = password_provider(); @@ -633,7 +633,7 @@ where O: AsRef, P: AsRef, Provider: FnMut() -> Option<&'p str>, - F: FnMut(io::Result) -> io::Result>, + F: FnMut(io::Result) -> io::Result>, Transform: TransformStrategy, { let password = password_provider(); @@ -664,7 +664,7 @@ pub(crate) fn run_entries<'p, P, Provider, F>( where P: AsRef, Provider: FnMut() -> Option<&'p str>, - F: FnMut(io::Result) -> io::Result<()>, + F: FnMut(io::Result) -> io::Result<()>, { let path = path.as_ref(); let provider = PathArchiveProvider(path); diff --git a/cli/src/command/extract.rs b/cli/src/command/extract.rs index ef40c8a7..aa7a040c 100644 --- a/cli/src/command/extract.rs +++ b/cli/src/command/extract.rs @@ -14,7 +14,7 @@ use crate::{ utils::{self, fmt::DurationDisplay, GlobPatterns}, }; use clap::{ArgGroup, Parser, ValueHint}; -use pna::{prelude::*, DataKind, EntryReference, Permission, ReadOptions, RegularEntry}; +use pna::{prelude::*, DataKind, EntryReference, NormalEntry, Permission, ReadOptions}; use rayon::ThreadPoolBuilder; #[cfg(target_os = "macos")] use std::os::macos::fs::FileTimesExt; @@ -202,7 +202,7 @@ where .build() .map_err(io::Error::other)?; - let mut hard_link_entries = Vec::::new(); + let mut hard_link_entries = Vec::::new(); let (tx, rx) = std::sync::mpsc::channel(); run_entries(path, password_provider, |entry| { @@ -237,7 +237,7 @@ where } pub(crate) fn extract_entry( - item: RegularEntry, + item: NormalEntry, password: Option<&str>, OutputOption { overwrite, diff --git a/cli/src/command/list.rs b/cli/src/command/list.rs index 70154264..08dc45fe 100644 --- a/cli/src/command/list.rs +++ b/cli/src/command/list.rs @@ -19,8 +19,8 @@ use clap::{ ArgGroup, Parser, }; use pna::{ - prelude::*, Compression, DataKind, Encryption, ExtendedAttribute, RawChunk, ReadEntry, - ReadOptions, RegularEntry, SolidHeader, + prelude::*, Compression, DataKind, Encryption, ExtendedAttribute, NormalEntry, RawChunk, + ReadEntry, ReadOptions, SolidHeader, }; use rayon::prelude::*; #[cfg(feature = "memmap")] @@ -98,7 +98,7 @@ struct TableRow { impl TryFrom<( - &RegularEntry, + &NormalEntry, Option<&str>, SystemTime, Option<&SolidHeader>, @@ -113,7 +113,7 @@ where #[inline] fn try_from( (entry, password, now, solid, numeric_owner): ( - &RegularEntry, + &NormalEntry, Option<&str>, SystemTime, Option<&SolidHeader>, @@ -266,7 +266,7 @@ pub(crate) fn run_list_archive( ReadEntry::Solid(_) => { log::warn!("This archive contain solid mode entry. if you need to show it use --solid option."); } - ReadEntry::Regular(item) => { + ReadEntry::Normal(item) => { entries.push((&item, password, now, None, args.numeric_owner).try_into()?) } } @@ -308,7 +308,7 @@ pub(crate) fn run_list_archive_mem( ReadEntry::Solid(_) => { log::warn!("This archive contain solid mode entry. if you need to show it use --solid option."); } - ReadEntry::Regular(item) => { + ReadEntry::Normal(item) => { entries.push((&item, password, now, None, args.numeric_owner).try_into()?) } } diff --git a/cli/src/command/strip.rs b/cli/src/command/strip.rs index bfa73038..91748840 100644 --- a/cli/src/command/strip.rs +++ b/cli/src/command/strip.rs @@ -11,7 +11,7 @@ use crate::{ utils::PathPartExt, }; use clap::{Args, Parser, ValueHint}; -use pna::{prelude::*, Metadata, RawChunk, RegularEntry}; +use pna::{prelude::*, Metadata, NormalEntry, RawChunk}; use std::{io, path::PathBuf}; #[derive(Args, Clone, Eq, PartialEq, Hash, Debug)] @@ -71,7 +71,7 @@ fn strip_metadata(args: StripCommand) -> io::Result<()> { } #[inline] -fn strip_entry_metadata(mut entry: RegularEntry, options: &StripOptions) -> RegularEntry +fn strip_entry_metadata(mut entry: NormalEntry, options: &StripOptions) -> NormalEntry where T: Clone, RawChunk: Chunk, diff --git a/cli/src/command/xattr.rs b/cli/src/command/xattr.rs index 06d6956b..f0d7cd1f 100644 --- a/cli/src/command/xattr.rs +++ b/cli/src/command/xattr.rs @@ -12,7 +12,7 @@ use crate::{ use base64::Engine; use clap::{Parser, ValueHint}; use indexmap::IndexMap; -use pna::RegularEntry; +use pna::NormalEntry; use std::{ fmt::{Display, Formatter, Write}, io, @@ -219,11 +219,11 @@ fn archive_set_xattr(args: SetXattrCommand) -> io::Result<()> { #[inline] fn transform_entry( - entry: RegularEntry, + entry: NormalEntry, name: Option<&str>, value: &[u8], remove: Option<&str>, -) -> RegularEntry { +) -> NormalEntry { let mut xattrs = entry .xattrs() .iter() diff --git a/cli/src/ext.rs b/cli/src/ext.rs index 11cd1874..cacf56d1 100644 --- a/cli/src/ext.rs +++ b/cli/src/ext.rs @@ -1,12 +1,12 @@ use crate::chunk::{self, Ace}; -use pna::{prelude::*, RawChunk, RegularEntry}; +use pna::{prelude::*, NormalEntry, RawChunk}; use std::io; -pub(crate) trait RegularEntryExt { +pub(crate) trait NormalEntryExt { fn acl(&self) -> io::Result>; } -impl RegularEntryExt for RegularEntry +impl NormalEntryExt for NormalEntry where RawChunk: Chunk, { diff --git a/lib/benches/create_extract.rs b/lib/benches/create_extract.rs index 7d4be4f5..daf90057 100644 --- a/lib/benches/create_extract.rs +++ b/lib/benches/create_extract.rs @@ -75,7 +75,7 @@ fn bench_read_archive_from_slice(b: &mut Bencher, mut options: WriteOptionsBuild let mut buf = Vec::with_capacity(1000); match item.unwrap() { ReadEntry::Solid(_) => (), - ReadEntry::Regular(item) => { + ReadEntry::Normal(item) => { item.reader(ReadOptions::with_password(Some("password"))) .unwrap() .read_to_end(&mut buf) diff --git a/lib/src/archive/read.rs b/lib/src/archive/read.rs index 388bb24c..2e709d35 100644 --- a/lib/src/archive/read.rs +++ b/lib/src/archive/read.rs @@ -3,7 +3,7 @@ mod slice; use crate::{ archive::{Archive, ArchiveHeader, PNA_HEADER}, chunk::{Chunk, ChunkReader, ChunkType, RawChunk}, - entry::{Entry, RawEntry, ReadEntry, RegularEntry}, + entry::{Entry, NormalEntry, RawEntry, ReadEntry}, }; #[cfg(feature = "unstable-async")] use futures_io::AsyncRead; @@ -148,11 +148,11 @@ impl Archive { /// /// An iterator over the entries in the archive. #[inline] - pub fn entries_skip_solid(&mut self) -> impl Iterator> + '_ { + pub fn entries_skip_solid(&mut self) -> impl Iterator> + '_ { self.entries().filter_map(|it| match it { Ok(e) => match e { ReadEntry::Solid(_) => None, - ReadEntry::Regular(r) => Some(Ok(r)), + ReadEntry::Normal(r) => Some(Ok(r)), }, Err(e) => Some(Err(e)), }) @@ -178,7 +178,7 @@ impl Archive { /// ReadEntry::Solid(solid_entry) => { /// // fill your code /// } - /// ReadEntry::Regular(entry) => { + /// ReadEntry::Normal(entry) => { /// // fill your code /// } /// } @@ -204,7 +204,7 @@ impl Archive { pub fn entries_with_password<'a>( &'a mut self, password: Option<&'a str>, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'a { self.entries().extract_solid_entries(password) } @@ -296,16 +296,16 @@ impl Archive { Ok(Some(RawEntry(chunks))) } - /// Read a [RegularEntry] from the archive. + /// Read a [NormalEntry] from the archive. /// This API is unstable. #[inline] - pub async fn read_entry_async(&mut self) -> io::Result> { + pub async fn read_entry_async(&mut self) -> io::Result> { loop { let entry = self.next_raw_item_async().await?; match entry { Some(entry) => match entry.try_into()? { ReadEntry::Solid(_) => continue, - ReadEntry::Regular(entry) => return Ok(Some(entry)), + ReadEntry::Normal(entry) => return Ok(Some(entry)), }, None => return Ok(None), }; @@ -335,7 +335,7 @@ impl<'r, R: Read> Entries<'r, R> { Self { reader } } - /// Returns an iterator that extract solid entries in the archive and returns a regular entry. + /// Returns an iterator that extract solid entries in the archive and returns a normal entry. /// /// # Example /// ```no_run @@ -354,8 +354,8 @@ impl<'r, R: Read> Entries<'r, R> { /// # } /// ``` #[inline] - pub fn extract_solid_entries(self, password: Option<&'r str>) -> RegularEntries<'r, R> { - RegularEntries { + pub fn extract_solid_entries(self, password: Option<&'r str>) -> NormalEntries<'r, R> { + NormalEntries { reader: self.reader, password, buf: Default::default(), @@ -373,14 +373,14 @@ impl<'r, R: Read> Iterator for Entries<'r, R> { } /// An iterator over the entries in the archive. -pub struct RegularEntries<'r, R> { +pub struct NormalEntries<'r, R> { reader: &'r mut Archive, password: Option<&'r str>, - buf: VecDeque>, + buf: VecDeque>, } -impl<'r, R: Read> Iterator for RegularEntries<'r, R> { - type Item = io::Result; +impl<'r, R: Read> Iterator for NormalEntries<'r, R> { + type Item = io::Result; #[inline] fn next(&mut self) -> Option { @@ -389,7 +389,7 @@ impl<'r, R: Read> Iterator for RegularEntries<'r, R> { } let entry = self.reader.read_entry(); match entry { - Ok(Some(ReadEntry::Regular(entry))) => Some(Ok(entry)), + Ok(Some(ReadEntry::Normal(entry))) => Some(Ok(entry)), Ok(Some(ReadEntry::Solid(entry))) => { let entries = entry.entries(self.password); match entries { diff --git a/lib/src/archive/read/slice.rs b/lib/src/archive/read/slice.rs index 6b8553f6..f2ec7b5a 100644 --- a/lib/src/archive/read/slice.rs +++ b/lib/src/archive/read/slice.rs @@ -1,6 +1,6 @@ use crate::{ archive::ArchiveHeader, chunk::read_chunk_from_slice, entry::RawEntry, Archive, Chunk, - ChunkType, Entry, RawChunk, ReadEntry, RegularEntry, PNA_HEADER, + ChunkType, Entry, NormalEntry, RawChunk, ReadEntry, PNA_HEADER, }; use std::borrow::Cow; use std::io; @@ -116,7 +116,7 @@ impl<'d> Archive<&'d [u8]> { /// ReadEntry::Solid(solid_entry) => { /// // fill your code /// } - /// ReadEntry::Regular(entry) => { + /// ReadEntry::Normal(entry) => { /// // fill your code /// } /// } @@ -211,7 +211,7 @@ impl<'a, 'r> Entries<'a, 'r> { Self { reader } } - /// Returns an iterator that extract solid entries in the archive and returns a regular entry. + /// Returns an iterator that extract solid entries in the archive and returns a normal entry. /// /// # Example /// @@ -233,12 +233,12 @@ impl<'a, 'r> Entries<'a, 'r> { pub fn extract_solid_entries( self, password: Option<&'r str>, - ) -> impl Iterator> + 'a + ) -> impl Iterator> + 'a where 'a: 'r, { self.flat_map(move |f| match f { - Ok(ReadEntry::Regular(r)) => vec![Ok(r.into())], + Ok(ReadEntry::Normal(r)) => vec![Ok(r.into())], Ok(ReadEntry::Solid(r)) => match r.entries(password) { Ok(entries) => entries.collect(), Err(e) => vec![Err(e)], diff --git a/lib/src/archive/write.rs b/lib/src/archive/write.rs index 47a6d6b0..79b542ec 100644 --- a/lib/src/archive/write.rs +++ b/lib/src/archive/write.rs @@ -5,7 +5,7 @@ use crate::{ compress::CompressionWriter, entry::{ get_writer, get_writer_context, Entry, EntryHeader, EntryName, EntryPart, Metadata, - RegularEntry, SealedEntryExt, SolidHeader, WriteCipher, WriteOptions, + NormalEntry, SealedEntryExt, SolidHeader, WriteCipher, WriteOptions, }, io::TryIntoInner, }; @@ -93,7 +93,7 @@ impl Archive { Ok(Self::new(write, header)) } - /// Write regular file entry into archive. + /// Write regular file as normal entry into archive. /// /// # Example /// ```no_run @@ -417,14 +417,14 @@ impl SolidArchive { /// # } /// ``` #[inline] - pub fn add_entry(&mut self, entry: RegularEntry) -> io::Result + pub fn add_entry(&mut self, entry: NormalEntry) -> io::Result where - RegularEntry: Entry, + NormalEntry: Entry, { entry.write_in(&mut self.inner) } - /// Write regular file entry into archive. + /// Write regular file as solid entry into archive. /// /// # Example /// ```no_run diff --git a/lib/src/entry.rs b/lib/src/entry.rs index fdae3a83..9e27babc 100644 --- a/lib/src/entry.rs +++ b/lib/src/entry.rs @@ -138,25 +138,25 @@ impl<'r> futures_io::AsyncRead for EntryDataReader<'r> { } } -/// A [RegularEntry] or [SolidEntry] read from an archive. +/// A [NormalEntry] or [SolidEntry] read from an archive. #[allow(clippy::large_enum_variant)] #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub enum ReadEntry> { /// Solid mode entry Solid(SolidEntry), - /// Regular entry - Regular(RegularEntry), + /// Normal entry + Normal(NormalEntry), } impl SealedEntryExt for ReadEntry where - RegularEntry: SealedEntryExt, + NormalEntry: SealedEntryExt, SolidEntry: SealedEntryExt, { #[inline] fn into_chunks(self) -> Vec { match self { - Self::Regular(r) => r.into_chunks(), + Self::Normal(r) => r.into_chunks(), Self::Solid(s) => s.into_chunks(), } } @@ -164,7 +164,7 @@ where #[inline] fn write_in(&self, writer: &mut W) -> io::Result { match self { - ReadEntry::Regular(r) => r.write_in(writer), + ReadEntry::Normal(r) => r.write_in(writer), ReadEntry::Solid(s) => s.write_in(writer), } } @@ -183,7 +183,7 @@ where if let Some(first_chunk) = entry.0.first() { match first_chunk.ty { ChunkType::SHED => Ok(Self::Solid(SolidEntry::try_from(entry)?)), - ChunkType::FHED => Ok(Self::Regular(RegularEntry::try_from(entry)?)), + ChunkType::FHED => Ok(Self::Normal(NormalEntry::try_from(entry)?)), _ => Err(io::Error::new(io::ErrorKind::InvalidData, "Invalid entry")), } } else { @@ -192,10 +192,10 @@ where } } -impl From> for ReadEntry { +impl From> for ReadEntry { #[inline] - fn from(value: RegularEntry) -> Self { - Self::Regular(value) + fn from(value: NormalEntry) -> Self { + Self::Normal(value) } } @@ -211,7 +211,7 @@ impl<'a> From>> for ReadEntry> { fn from(value: ReadEntry>) -> Self { match value { ReadEntry::Solid(s) => Self::Solid(s.into()), - ReadEntry::Regular(r) => Self::Regular(r.into()), + ReadEntry::Normal(r) => Self::Normal(r.into()), } } } @@ -221,7 +221,7 @@ impl<'a> From> for ReadEntry> { fn from(value: ReadEntry<&'a [u8]>) -> Self { match value { ReadEntry::Solid(s) => Self::Solid(s.into()), - ReadEntry::Regular(r) => Self::Regular(r.into()), + ReadEntry::Normal(r) => Self::Normal(r.into()), } } } @@ -231,7 +231,7 @@ impl<'a> From>> for ReadEntry> { fn from(value: ReadEntry>) -> Self { match value { ReadEntry::Solid(s) => Self::Solid(s.into()), - ReadEntry::Regular(r) => Self::Regular(r.into()), + ReadEntry::Normal(r) => Self::Normal(r.into()), } } } @@ -241,7 +241,7 @@ impl<'a> From> for ReadEntry> { fn from(value: ReadEntry<&'a [u8]>) -> Self { match value { ReadEntry::Solid(s) => Self::Solid(s.into()), - ReadEntry::Regular(r) => Self::Regular(r.into()), + ReadEntry::Normal(r) => Self::Normal(r.into()), } } } @@ -249,7 +249,7 @@ impl<'a> From> for ReadEntry> { pub(crate) struct EntryIterator<'s>(EntryReader>); impl Iterator for EntryIterator<'_> { - type Item = io::Result; + type Item = io::Result; #[inline] fn next(&mut self) -> Option { @@ -420,7 +420,7 @@ impl> SolidEntry { /// // fill your code /// } /// } - /// ReadEntry::Regular(entry) => { + /// ReadEntry::Normal(entry) => { /// // fill your code /// } /// } @@ -432,7 +432,7 @@ impl> SolidEntry { pub fn entries( &self, password: Option<&str>, - ) -> io::Result> + '_> { + ) -> io::Result> + '_> { let reader = decrypt_reader( crate::io::FlattenReader::new(self.data.iter().map(|it| it.as_ref()).collect()), self.header.encryption, @@ -560,7 +560,7 @@ where /// [Entry] that read from PNA archive. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] -pub struct RegularEntry> { +pub struct NormalEntry> { pub(crate) header: EntryHeader, pub(crate) phsf: Option, pub(crate) extra: Vec>, @@ -569,7 +569,14 @@ pub struct RegularEntry> { pub(crate) xattrs: Vec, } -impl TryFrom> for RegularEntry +#[deprecated( + note = "Renamed to `libpna::NormalEntry`. This type alias will be removed in libpna version 0.22.0.", + since = "0.19.0" +)] +/// Type alias of [NormalEntry] +pub type RegularEntry = NormalEntry; + +impl TryFrom> for NormalEntry where RawChunk: Chunk, { @@ -656,7 +663,7 @@ where } } -impl SealedEntryExt for RegularEntry> { +impl SealedEntryExt for NormalEntry> { fn into_chunks(self) -> Vec { let Metadata { raw_file_size, @@ -767,7 +774,7 @@ impl SealedEntryExt for RegularEntry> { } } -impl SealedEntryExt for RegularEntry<&[u8]> { +impl SealedEntryExt for NormalEntry<&[u8]> { fn into_chunks(self) -> Vec { let Metadata { raw_file_size, @@ -878,7 +885,7 @@ impl SealedEntryExt for RegularEntry<&[u8]> { } } -impl<'a> SealedEntryExt for RegularEntry> { +impl<'a> SealedEntryExt for NormalEntry> { fn into_chunks(self) -> Vec { let Metadata { raw_file_size, @@ -989,9 +996,9 @@ impl<'a> SealedEntryExt for RegularEntry> { } } -impl Entry for RegularEntry where RegularEntry: SealedEntryExt {} +impl Entry for NormalEntry where NormalEntry: SealedEntryExt {} -impl RegularEntry { +impl NormalEntry { /// Information in the header of the entry. #[inline] pub fn header(&self) -> &EntryHeader { @@ -1057,7 +1064,7 @@ impl RegularEntry { } } -impl RegularEntry { +impl NormalEntry { /// Apply extra chunks to the entry. /// /// # Example @@ -1081,8 +1088,8 @@ impl RegularEntry { } } -impl> RegularEntry { - /// Return the reader of this [`RegularEntry`]. +impl> NormalEntry { + /// Return the reader of this [`NormalEntry`]. /// /// # Examples /// ```no_run @@ -1118,9 +1125,9 @@ impl> RegularEntry { } } -impl<'a> From>> for RegularEntry> { +impl<'a> From>> for NormalEntry> { #[inline] - fn from(value: RegularEntry>) -> Self { + fn from(value: NormalEntry>) -> Self { Self { header: value.header, phsf: value.phsf, @@ -1132,9 +1139,9 @@ impl<'a> From>> for RegularEntry> { } } -impl<'a> From> for RegularEntry> { +impl<'a> From> for NormalEntry> { #[inline] - fn from(value: RegularEntry<&'a [u8]>) -> Self { + fn from(value: NormalEntry<&'a [u8]>) -> Self { Self { header: value.header, phsf: value.phsf, @@ -1146,9 +1153,9 @@ impl<'a> From> for RegularEntry> { } } -impl<'a> From>> for RegularEntry> { +impl<'a> From>> for NormalEntry> { #[inline] - fn from(value: RegularEntry>) -> Self { + fn from(value: NormalEntry>) -> Self { Self { header: value.header, phsf: value.phsf, @@ -1160,9 +1167,9 @@ impl<'a> From>> for RegularEntry> { } } -impl<'a> From> for RegularEntry> { +impl<'a> From> for NormalEntry> { #[inline] - fn from(value: RegularEntry<&'a [u8]>) -> Self { + fn from(value: NormalEntry<&'a [u8]>) -> Self { Self { header: value.header, phsf: value.phsf, diff --git a/lib/src/entry/builder.rs b/lib/src/entry/builder.rs index 2b96dcd8..d6ca4b16 100644 --- a/lib/src/entry/builder.rs +++ b/lib/src/entry/builder.rs @@ -4,7 +4,7 @@ use crate::{ compress::CompressionWriter, entry::{ get_writer, get_writer_context, private::SealedEntryExt, DataKind, Entry, EntryHeader, - EntryName, EntryReference, ExtendedAttribute, Metadata, Permission, RegularEntry, + EntryName, EntryReference, ExtendedAttribute, Metadata, NormalEntry, Permission, SolidEntry, SolidHeader, WriteCipher, WriteOptions, }, io::TryIntoInner, @@ -24,7 +24,7 @@ use std::{ const MAX_CHUNK_DATA_LENGTH: usize = u32::MAX as usize; -/// A builder for creating a new [RegularEntry]. +/// A builder for creating a new [NormalEntry]. pub struct EntryBuilder { header: EntryHeader, phsf: Option, @@ -290,13 +290,13 @@ impl EntryBuilder { self } - /// Builds the entry and returns a Result containing the new [RegularEntry]. + /// Builds the entry and returns a Result containing the new [NormalEntry]. /// /// # Returns /// - /// A Result containing the new [RegularEntry], or an I/O error if the build fails. + /// A Result containing the new [NormalEntry], or an I/O error if the build fails. #[inline] - pub fn build(self) -> io::Result { + pub fn build(self) -> io::Result { let mut data = if let Some(data) = self.data { data.try_into_inner()?.try_into_inner()?.inner } else { @@ -316,7 +316,7 @@ impl EntryBuilder { accessed: self.accessed, permission: self.permission, }; - Ok(RegularEntry { + Ok(NormalEntry { header: self.header, phsf: self.phsf, extra: self.extra_chunks, @@ -435,9 +435,9 @@ impl SolidEntryBuilder { /// # } /// ``` #[inline] - pub fn add_entry(&mut self, entry: RegularEntry) -> io::Result + pub fn add_entry(&mut self, entry: NormalEntry) -> io::Result where - RegularEntry: Entry, + NormalEntry: Entry, { entry.write_in(&mut self.data) } diff --git a/lib/tests/extract_solid_compatibility.rs b/lib/tests/extract_solid_compatibility.rs index 97d3fb0c..44802bbb 100644 --- a/lib/tests/extract_solid_compatibility.rs +++ b/lib/tests/extract_solid_compatibility.rs @@ -1,7 +1,7 @@ -use libpna::{Archive, DataKind, ReadEntry, ReadOptions, RegularEntry}; +use libpna::{Archive, DataKind, NormalEntry, ReadEntry, ReadOptions}; use std::io; -fn assert_entry(item: RegularEntry, password: Option<&str>) { +fn assert_entry(item: NormalEntry, password: Option<&str>) { let path = item.header().path().as_str(); let mut dist = Vec::new(); let mut reader = item.reader(ReadOptions::with_password(password)).unwrap(); @@ -75,7 +75,7 @@ fn extract_all(bytes: &[u8], password: Option<&str>) { assert_entry(item, password); } } - ReadEntry::Regular(item) => { + ReadEntry::Normal(item) => { if item.header().data_kind() == DataKind::Directory { continue; } diff --git a/pna/src/ext.rs b/pna/src/ext.rs index d95fda5a..06b34a13 100644 --- a/pna/src/ext.rs +++ b/pna/src/ext.rs @@ -4,7 +4,7 @@ mod metadata; pub use archive::*; pub use entry::*; -use libpna::{Archive, Metadata, RegularEntry}; +use libpna::{Archive, Metadata, NormalEntry}; pub use metadata::*; use std::fs; @@ -14,5 +14,5 @@ mod private { pub trait Sealed {} impl Sealed for Archive {} impl Sealed for Metadata {} - impl Sealed for RegularEntry {} + impl Sealed for NormalEntry {} } diff --git a/pna/src/ext/entry.rs b/pna/src/ext/entry.rs index adf051e4..260a2719 100644 --- a/pna/src/ext/entry.rs +++ b/pna/src/ext/entry.rs @@ -1,8 +1,8 @@ use super::private; -use libpna::{EntryBuilder, RegularEntry, WriteOptions}; +use libpna::{EntryBuilder, NormalEntry, WriteOptions}; use std::{fs, io, path::Path}; -/// [RegularEntry] extension method trait. +/// [NormalEntry] extension method trait. pub trait EntryFsExt: private::Sealed { /// Create Entry from a given path. /// @@ -22,7 +22,7 @@ pub trait EntryFsExt: private::Sealed { Self: Sized; } -impl EntryFsExt for RegularEntry { +impl EntryFsExt for NormalEntry { /// Create Entry from a given path. /// /// # Errors @@ -34,10 +34,10 @@ impl EntryFsExt for RegularEntry { /// ```no_run /// # use std::io::{self, prelude::*}; /// use pna::prelude::*; - /// use pna::RegularEntry; + /// use pna::NormalEntry; /// /// # fn main() -> io::Result<()> { - /// RegularEntry::from_path("path/to/file")?; + /// NormalEntry::from_path("path/to/file")?; /// # Ok(()) /// # } /// ``` @@ -57,10 +57,10 @@ impl EntryFsExt for RegularEntry { /// ```no_run /// # use std::io::{self, prelude::*}; /// use pna::prelude::*; - /// use pna::{RegularEntry, WriteOptions}; + /// use pna::{NormalEntry, WriteOptions}; /// /// # fn main() -> io::Result<()> { - /// RegularEntry::from_path_with("path/to/file", WriteOptions::store())?; + /// NormalEntry::from_path_with("path/to/file", WriteOptions::store())?; /// # Ok(()) /// # } /// ```