Skip to content

Commit

Permalink
Merge pull request #13 from phip1611/dev2
Browse files Browse the repository at this point in the history
add error handling (don't panic in constructor)
  • Loading branch information
phip1611 authored May 3, 2024
2 parents 14097e0 + 5678892 commit 66f8130
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 67 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-patch" ]
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
4 changes: 2 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: QA

on: [ push, pull_request ]
on: [ push, pull_request, merge_group ]

jobs:
spellcheck:
name: Spellcheck
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Executes "typos ."
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Build

on: [push, pull_request]
on: [ push, pull_request, merge_group ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ${{ matrix.runs-on }}
runs-on: "${{ matrix.runs-on }}"
strategy:
matrix:
runs-on:
Expand All @@ -16,16 +16,16 @@ jobs:
rust:
- stable
- nightly
- 1.63.0 # MSVR
- 1.76.0 # MSVR
steps:
- uses: actions/checkout@v2
# Important preparation step: override the latest default Rust version in GitHub CI
# with the current value of the iteration in the "strategy.matrix.rust"-array.
- uses: actions-rs/toolchain@v1
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: default
toolchain: ${{ matrix.rust }}
override: true
toolchain: "${{ matrix.rust }}"
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.runs-on }}-${{ matrix.rust }}"
- name: Build
run: cargo build --all-targets --verbose --features alloc
# use some arbitrary no_std target
Expand All @@ -41,16 +41,16 @@ jobs:
strategy:
matrix:
rust:
- 1.63.0
- stable
steps:
- uses: actions/checkout@v2
# Important preparation step: override the latest default Rust version in GitHub CI
# with the current value of the iteration in the "strategy.matrix.rust"-array.
- uses: actions-rs/toolchain@v1
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "${{ matrix.rust }}"
- uses: Swatinem/rust-cache@v2
with:
profile: default
toolchain: ${{ matrix.rust }}
override: true
key: "${{ matrix.runs-on }}-${{ matrix.rust }}"
- name: Rustfmt
run: cargo fmt -- --check
- name: Clippy
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# v0.3.0 (2024-05-03)
- MSRV is now 1.76 stable
- added support for more Tar archives
- 256 character long filename support (prefix + name)
- add support for space terminated numbers
- non-null terminated names
- iterate over directories: read regular files from directories
- more info: <https://github.com/phip1611/tar-no-std/pull/10>
- `TarArchive[Ref]::new` now returns a result
- added `unstable` feature with enhanced functionality for `nightly` compilers
- error types implement `core::error::Error`

# v0.2.0 (2023-04-11)
- MSRV is 1.60.0
- bitflags bump: 1.x -> 2.x
Expand Down
19 changes: 12 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name = "tar-no-std"
description = """
Library to read Tar archives (by GNU Tar) in `no_std` contexts with zero allocations.
The crate is simple and only supports reading of "basic" archives, therefore no extensions, such
as GNU Longname. The maximum supported file name length is 256 characters excluding the NULL-byte
(using the tar name/prefix longname implementation).The maximum supported file size is 8GiB.
as GNU Longname. The maximum supported file name length is 256 characters excluding the NULL-byte
(using the tar name/prefix longname implementation).The maximum supported file size is 8GiB.
Directories are supported, but only regular fields are yielded in iteration.
"""
version = "0.2.0"
version = "0.3.0"
edition = "2021"
keywords = ["tar", "tarball", "archive"]
categories = ["data-structures", "no-std", "parser-implementations"]
Expand All @@ -16,23 +16,28 @@ license = "MIT"
homepage = "https://github.com/phip1611/tar-no-std"
repository = "https://github.com/phip1611/tar-no-std"
documentation = "https://docs.rs/tar-no-std"
rust-version = "1.76.0"

# required because "env_logger" uses "log" but with dependency to std..
resolver = "2"

[features]
default = []
alloc = []
unstable = [] # requires nightly

[[example]]
name = "alloc_feature"
required-features = ["alloc"]

[dependencies]
bitflags = "2.0"
bitflags = "2.5"
log = { version = "0.4", default-features = false }
memchr = { version = "2.6.3", default-features = false }
num-traits = { version = "0.2.16", default-features = false }
memchr = { version = "2.7", default-features = false }
num-traits = { version = "~0.2", default-features = false }

[dev-dependencies]
env_logger = "0.10"
env_logger = "0.11"

[package.metadata.docs.rs]
all-features = true
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `tar-no-std` - Parse Tar Archives (Tarballs)

_Due to historical reasons, there are several formats of tar archives. All of them are based on the same principles,
but have some subtle differences that often make them incompatible with each other._ [[0]]
but have some subtle differences that often make them incompatible with each other._ [0]

Library to read Tar archives (by GNU Tar) in `no_std` contexts with zero allocations. If you have a standard
environment and need full feature support, I recommend the use of <https://crates.io/crates/tar> instead.
Expand Down Expand Up @@ -52,7 +52,8 @@ If your tar file is compressed, e.g. by `.tar.gz`/`gzip`, you need to uncompress
bytes.

## MSRV
The MSRV is 1.52.1 stable.
The MSRV is 1.76.0 stable.


[0]: https://www.gnu.org/software/tar/manual/html_section/Formats.html
## References
[0]\: https://www.gnu.org/software/tar/manual/html_section/Formats.html
2 changes: 1 addition & 1 deletion examples/alloc_feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() {
// also works in no_std environment (except the println!, of course)
let archive = include_bytes!("../tests/gnu_tar_default.tar");
let archive_heap_owned = archive.to_vec().into_boxed_slice();
let archive = TarArchive::new(archive_heap_owned);
let archive = TarArchive::new(archive_heap_owned).unwrap();
// Vec needs an allocator of course, but the library itself doesn't need one
let entries = archive.entries().collect::<Vec<_>>();
println!("{:#?}", entries);
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() {

// also works in no_std environment (except the println!, of course)
let archive = include_bytes!("../tests/gnu_tar_default.tar");
let archive = TarArchiveRef::new(archive);
let archive = TarArchiveRef::new(archive).unwrap();
// Vec needs an allocator of course, but the library itself doesn't need one
let entries = archive.entries().collect::<Vec<_>>();
println!("{:#?}", entries);
Expand Down
Loading

0 comments on commit 66f8130

Please sign in to comment.