The primary feature of this release is adding some internal-for-now environment variables that allow the end user to change the level of compression at runtime. The primary motivator of this is improving the speed of testing dist. PR/212
This release also includes some general dependency updates.
The design of APIs has been massively overhauled and normalized, with the changes too substantial to individually enumerate. Major highlights:
- Asset (the union between LocalAsset and RemoteAsset) has been removed
- RemoteAsset is largely replaced with AxoClient which to allow you to actually initialized/configure the underlying reqwest client
- Errors cleaned up
- Function names cleaned up to be unambiguous and normal
- "missing" APIs added
Fixes the pub use reqwest
that was added in the previous version.
- RemoteAsset: fix mimetype requirement - mistydemeo, pr126
Fixes an issue where functions like RemoteAsset::copy
would fail on files without specific mimetypes. We used this to assign file extensions based on mimetype, but it shouldn't have rejected other files.
- RemoteAsset: exposes reqwest - mistydemeo, pr137
- LocalAsset: fixes a misleading error message - sorairolake, pr126
Updates several dependencies.
Relaxes the reqwest
dependency range.
Updates several dependencies.
Reduces the dependency tree when the remote
feature isn't in use by properly scoping the image
dependency.
Fixes a branching error in the previous release which prevented the ZIP fix from being usable.
- Zipping directory trees on Windows - mistydemeo, pr94
Recursive directory trees on Windows would be zipped with mangled filenames; this has been fixed by preprocessing the file names before passing them to the zip
crate.
- Parsing JSON containing byte order marks - mistydemeo, pr87
This fixes an issue parsing JSON from files containing a byte order mark. This is rare, but can occur with JSON files created in Windows with certain software, including data written to disk in PowerShell.
The underlying JSON parsing library used by axoasset doesn't currently support parsing JSON files that begin with a byte order mark. In this release, we strip it from files that contain it before passing it to serde in order to work around this limitation.
- Extract archives - mistydemeo, pr84
Adds the ability to decompress tarballs and ZIP files from LocalAsset
. Users can extract an entire archive to a directory via the untar_gz_all
/untar_xz_all
/untar_zstd_all
/unzip_all
methods, or extract individual files to bytearrays of their contents via the untar_gz_file
/untar_xz_file
/untar_zstd_file
/unzip_file
metods.
Updates dependencies, including a breaking upgrade to miette. Users of this crate will need to update to at least miette 6.0.0.
Fixes zstd compression to actually use zstd, whoops!
Minor updates to dependencies to reduce the amount of compression libraries we dynamically link.
-
New reexports - mistydemeo, pr68
Reexports
toml
,toml_edit
andserde_json
. Types from these three crates appear in certain axoasset function signatures.
-
Reduce dependency tree size - mistydemeo, [pr66]
Reduces the size of axoasset's dependency tree by not installing unused features from the
images
dependency.
-
Add a with_root argument to compression methods - Gankra, pr61
The compression methods take a path to a directory to tar/zip up. The with_root argument specifies a root prefix of directories that the archive's contents should be nested under. If None then the dir's contents are flattened into the root of the archive.
e.g. to make a tar.gz that matches the npm package format (which wants the tarball to contain a dir named "package"), you can compress:
"path/to/contents/", Some("package")
-
Add more copying APIs to LocalAsset - Gankra, pr62
LocalAsset now includes
copy_named
,copy_dir
, andcopy_dir_named
. Allcopy
functions were change to return aUtf8PathBuf
instead of aPathBuf
.
-
SourceFile::deserialize_toml_edit (behind new toml-edit feature) - Gankra, pr52
Just a convenience to read a SourceFile as toml-edit and map the error spans to the right format.
-
Separate compression into cargo features - shadows-withal, pr47
The APIs for processing tarballs/zips are now behind "compression-tar" and "compression-zip", with a convenience "compression" feature that covers both.
-
LocalAsset API cleanup - shadows-withal, pr48
Some breaking cleanups to APIs to make them more ergonomic longterm
- Many APIs that previously took Strings now take
AsRef<Utf8Path>
- write_new_{all} now just takes a path to the file, instead of folder_path + name
- Many APIs that previously took Strings now take
-
update github CI - striezel, pr50
Updating several old Github CI actions to more modern/maintained versions, thanks a ton!
-
โจ New
LocalAsset
functionality! - shadows-withal, pr38, pr46We've added a lot more functions to
LocalAsset
:write_new_all
, to write a file and its parent directoriescreate_dir
, which creates, well, a new directorycreate_dir_all
, which creates a directory and its parent directoriesremove_file
, which deletes a fileremove_dir
, which deletes an empty directoryremove_dir_all
, which deletes a directory and its contentstar_{gz,xz,zstd}_dir
, which are three separate functions that create a tar archive with the specified compression algorithm, either Gzip, Xzip, or Zstdzip_dir
, which creates a zip archive
-
โจ New feature:
SourceFile::span_for_substr
- Gankra, pr35This function enables the ability to get spans even when using a tool that doesn't support them as long as it returns actual substrings pointing into the original SourceFile's inner String.
-
Simply SourceFile::new and new_empty - Gankra, pr43
SourceFile::new and new_empty no longer return Results and simply use the origin_path as the file name, making them appropriate for synthetic/test inputs that don't map to actual files.
- Fix compilation errors for features and add tests - Gankra/ashleygwilliams, pr33
-
โจ New type:
SourceFile
- Gankra, pr25SourceFile
is a new asset type which is a readonly String version ofAsset
wrapped in anArc
. The purpose of this type is to be cheap to clone and pass around everywhere so that errors can refer to it (using the miette#[source_code]
and#[label]
attributes). TheArc
ensures this is cheap at minimal overhead. The String ensures the contents make sense to display. -
โจ New type:
Spanned
- Gankra, pr25Spanned<T>
is a new type which tries to behave likeBox<T>
in the sense that it's "as if" it's aT
but with source span info embedded. If you want to remember that a value was decoded from an asset at bytes 100 to 200, you can wrap it in aSpanned
without disrupting any of the code that uses it. Then if you determine that value caused a problem, you can callSpanned::span(&value)
to extract the span and have miette include the asset context in the error message. -
โจ New features:
serde_json
andtoml-rs
- Gankra, pr25json-serde
andtoml-serde
are new features which pull in dedicated support forserde_json
andtoml-rs
. These features adddeserialize_json
anddeserialize_toml
methods toSourceFile
which understand those crates' native error types and produce full pretty miette-y errors when deserializing, like this:ร failed to read JSON โฐโโถ trailing comma at line 3 column 1 โญโ[src/tests/res/bad-package.json:2:1] 2 โ "name": null, 3 โ } ยท โ โฐโโโโ
(In this case serde_json itself points at the close brace and not the actual comma, we're just faithfully forwarding that.)
Spanned
has special integration withtoml-rs
, because it's actually a fork of that crate's own magicSpanned
type. If you deserialize a struct that contains aSpanned<T>
it will automagically fill in the span info for you. Ours further improves on this by putting in more effort to be totally transparent likeBox
. -
โจ New function:
write_new
forLocalAsset
- ashleygwilliams, pr28axoasset was first conceived to handle assets declared by end users for use in
oranda
, but quickly grew to encompass all fs/network calls. one of the things we often need to do is create a new file. This is only available onLocalAsset
as, at least for the moment, that is the only place axoasset has permissions to create new assets. -
make
RemoteAsset
an optional feature - Gankra, pr26A feature of
axoasset
is that it is agnostic to the origin of the asset: it can be local or remote. However, often, authors can be certain that they will only be using local assets. In this case, it reduces dependencies to not include the remote functionality. Previously this wasn't possible! -
miette-ify
errors - Gankra, pr24Previously we were using
thiserror
for error handling, but to be consistent across our toolchain, we've updated our errors to usemiette
. This has the added benefit of formalizing structures we were informally building into our error types (help/diagnostic text, forwarding the bare error as details, etc). -
consistent
Asset
interface - ashleygwilliams, pr30With 3 asset types,
LocalAsset
,RemoteAsset
, andSourceFile
, it felt important to align their structures so they could be used nearly identically. Every type now has a:origin_path
: the original source of the filefilename
: derived from theorigin_path
and, in the case ofRemoteAsset
s also the headers from the network response.contents
: the contents of the asset as bytes or a String depending on asset type
Initial release.