5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2025-01-09 05:17:38 +03:00
Commit Graph

148 Commits

Author SHA1 Message Date
Stefan Reiter
8a9c71c035 decoder/aio: add contents() and content_size() calls
Returns a decoder::Contents without a wrapper type, since in this case
we don't want to hide the SeqRead implementation (as done in
decoder::sync). For conviencience also implement AsyncRead if "tokio-io"
is enabled.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-03-31 13:52:24 +02:00
Wolfgang Bumiller
eae6dc06af rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:52:09 +02:00
Wolfgang Bumiller
e827b69a60 encoder: only flush owned outputs in 'finish'
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:51:46 +02:00
Dominik Csapak
d995b5319d encoder: flush after writing last entry
some writers may need to be flushed to write out all data

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-03-25 07:31:16 +01:00
Wolfgang Bumiller
737f75cf97 rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-12 10:42:14 +01:00
Wolfgang Bumiller
180186c567 explicitly pad StatxTimestamp with zeros
otherwise we can have random data in there

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-12 10:34:55 +01:00
Wolfgang Bumiller
b8d79e5fc7 add EncoderOutput::to_borrowed()
may more "explicit" than using `.as_mut().into()`, but
otherwise just seems like a useful addition to show the
lifetime constraints on this

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-17 09:51:38 +01:00
Wolfgang Bumiller
f904859816 revert Send requirement from previous patch
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-17 09:23:37 +01:00
Stefan Reiter
d84024338a make aio::Encoder actually behave with async
To really use the encoder with async/await, it needs to support
SeqWrite implementations that are Send. This requires changing a whole
bunch of '&mut dyn SeqWrite' trait objects to instead take a 'T:
SeqWrite' generic parameter directly instead. Most of this is quite
straightforward, though incurs a lot of churn (FileImpl needs a generic
parameter now for example).

The trickiest part is returning a new Encoder instance in
create_directory, as the trait object trick with
SeqWrite::as_trait_object doesn't work if SeqWrite is implemented for
generic '&mut S'.

Instead, work with the generic object directly, and express the
owned/borrowed state in the Encoder (to avoid nested borrowing) as an
enum EncoderOutput.

Add to the aio test to ensure the Encoder is now actually useable.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-17 09:20:40 +01:00
Wolfgang Bumiller
8bff2f7c7e cargo fmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-02 10:54:36 +01:00
Wolfgang Bumiller
574cfa09bc make Send test not depend on tokio
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-02 10:54:11 +01:00
Wolfgang Bumiller
a08b84b79b fix Encoder to be Send + Sync
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-02 10:47:56 +01:00
Wolfgang Bumiller
ae14f6c072 typo fix: this was supposed to be from_tokio
it's on `tokio-io` after all and there previously used to be
a `form_futures` for the `Async*` traits from `futures`

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-01-15 14:42:31 +01:00
Wolfgang Bumiller
1646a72d3f clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-01-15 14:24:50 +01:00
Fabian Grünbichler
43c585cd83 build: fix --no-default-features
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-01-14 15:26:16 +01:00
Fabian Grünbichler
7aee9c1f6b remove futures-io feature
we don't use it, and it adds unnecessary duplication/complexity.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-01-12 11:35:39 +01:00
Fabian Grünbichler
8de202d4c4 clippy: use matches! instead of match
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-01-11 14:48:15 +01:00
Fabian Grünbichler
6e02c1221c update to tokio 1.0
unfortunately, futures::io::AsyncRead and tokio::io::AsyncRead no longer
share a do_poll_read signature, so we need to adapt one to the other
(and also no longer generate some wrapper implementations via macro).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-12-29 13:58:38 +01:00
Wolfgang Bumiller
318462ea3d fix decode_entry on special files
When using the random accessor to access FIFOs or sockets,
the ranged reader limits the data to only that entry, and
the `decode_entry` will never see a `PAYLOAD` or
`GOODBYE_TABLE` item to finish the entry.
Instead, it'll reach EOF and we need to handle this.
The accessor now tells the decoder to expect EOF as a valid
condition for ending the entry.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-12-15 11:34:15 +01:00
Wolfgang Bumiller
9e7287abc1 clippy
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-27 11:55:07 +01:00
Dietmar Maurer
1568a7546d Decoder<StandardReader<T>>: allow access to input
We need this to query the status of the input when decode fails.
2020-09-18 11:32:43 +02:00
Wolfgang Bumiller
420639374d formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 09:00:13 +02:00
Wolfgang Bumiller
84a1926f44 encoder: let finish return writer, add into_writer
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-27 12:04:18 +02:00
Wolfgang Bumiller
2ea8aff22d rename Entry to Stat, add Metadata::builder_from_stat
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-25 12:25:07 +02:00
Wolfgang Bumiller
ec4a53edce drop poll_close and poll_position from SeqWrite
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-24 12:00:39 +02:00
Wolfgang Bumiller
fc2f1b9f20 doc fixup
This is a SignedDuration now instead of a Result

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-24 12:00:39 +02:00
Wolfgang Bumiller
bb6779b5a0 introduce StatxTimestamp helper type
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-24 12:00:39 +02:00
Wolfgang Bumiller
644e844d49 implement Entry v2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 07:33:41 +02:00
Wolfgang Bumiller
939f24689f introduce StatxTimestamp helper type
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 07:23:53 +02:00
Wolfgang Bumiller
f0279c01e0 add format description to format module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 07:23:17 +02:00
Wolfgang Bumiller
1b25fc0820 more clippy lints
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-16 11:40:41 +02:00
Wolfgang Bumiller
93fef2fd8a clippy: fix bad cast in max allowed content size
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-16 11:21:06 +02:00
Wolfgang Bumiller
cde0236c1c accessor: impl ReadAt for byte slices
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-26 13:54:16 +02:00
Wolfgang Bumiller
4c3318a28e acl: User/Group::new method
with some convenience to not require the Permissions type
wraparound.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-26 13:05:05 +02:00
Wolfgang Bumiller
08bc9bbc6c rustc compat fixup
lowers crate's rustc requirement to << 1.43

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-26 11:44:25 +02:00
Wolfgang Bumiller
0104cf77b7 add test-harness feature for separate unit tests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-25 13:51:22 +02:00
Wolfgang Bumiller
611401f9f0 sync encoder: fix metadat lifetime leaking into encoder
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-25 13:51:22 +02:00
Wolfgang Bumiller
0f109bf701 Add a metadata builder
for now primarily to get started with tests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-25 13:51:22 +02:00
Wolfgang Bumiller
37774a671d formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-25 12:14:07 +02:00
Wolfgang Bumiller
1b1e52a46a new hashes for the entire archive foramt
This breaks all previous pxar files and represents a clear
cut off of the catar format.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-24 13:31:34 +02:00
Wolfgang Bumiller
8d9968f4c8 sort some constants
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-24 11:54:47 +02:00
Wolfgang Bumiller
710e6c8b4d formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-24 11:53:55 +02:00
Wolfgang Bumiller
e72062a97a make ReadAt trait more correct
A simple `poll_read_at` with an immutable self reference
lacks the information which poll *operation* is being
polled. An associated type won't work well enough
(particularly with trait objects and lifetimes), and GATs
are unstable (and not advanced enough yet), so we need to
improvise.

To be more async-friendly, the `start_read_at()` method's
Pending now includes a reference to the operation which also
grabs the buffer lifetime, and has to be completed with
`poll_complete()`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-24 11:53:32 +02:00
Wolfgang Bumiller
4af1594473 doc update
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-22 11:39:17 +02:00
Wolfgang Bumiller
16f0464d8d fix device encoding
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-22 11:05:11 +02:00
Wolfgang Bumiller
fd99ae79bc decoder: remove pub(crate) from some internal items
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-15 10:34:54 +02:00
Wolfgang Bumiller
1187920fff accessor: don't mess with internal decoder state
skipping a filename is trivial enough to not abuse internal
decoder methods

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-15 10:33:06 +02:00
Fabian Grünbichler
a191c6a76a decoder: fix typos
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 09:46:07 +02:00
Fabian Grünbichler
4a13b8a3e4 header: implement Display
for nicer/readable error messages.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 09:46:04 +02:00
Fabian Grünbichler
ec0761f9db header: add size checks
to catch
- headers with full_size < size_of::<Header>
- headers with content_size > header-specific limit

both should in practice only occur for corrupted streams/archives, but
panic-ing/attempting to allocate huge amounts of memory should be
avoided even for those.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 09:46:01 +02:00