[pbs-devel] [RFC v2 pxar 02/36] encoder: add optional output writer for file payloads

Christian Ebner c.ebner at proxmox.com
Mon Mar 11 14:50:23 CET 2024


On 3/11/24 14:21, Fabian Grünbichler wrote:
> On March 5, 2024 10:26 am, Christian Ebner wrote:
> 
> should we prevent/catch this being called multiple times?

The attaching of the optional payload output being possible
at any time and even multiple times is something Dietmar noticed as
well.

I will follow his suggestion here and add this as an optional parameter
to the encoders `new` method, which will handle this better at the cost
of breaking the API. Are there objections to that?

> 
> 
> this part here and the read counter-part in the next commit basically
> hard-code the format of this entry type, maybe that could be handled
> nicer? e.g., construct a PayloadRef here, and let that implement the
> conversion to/from data?
> 
> it is a pre-existing pattern here though ;)
>

Okay, will have a look on how to handle the serialization in a more
generic way, especially since the `PayloadRef` struct will be used
later in the decoder anyway (therefore already have that), so it might
make sense to e.g. have a trait for all pxar entry types to that
guarantees the serialization methods.

Is that what you had in mind here?


> 
> nit: the two if-lets could be combined:
> 
> if let EncoderOutput::Owned(Some(output)) = &mut self.payload_output {
>      ..
> }
> 

Forgot to `cargo clippy` these patches, which also suggests to combine
these. Will be addressed in a followup version of the patches.




More information about the pbs-devel mailing list