Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

http: Multiple arg of Cids/IpfsPath #352

Open
koivunej opened this issue Sep 1, 2020 · 1 comment
Open

http: Multiple arg of Cids/IpfsPath #352

koivunej opened this issue Sep 1, 2020 · 1 comment

Comments

@koivunej
Copy link
Collaborator

koivunej commented Sep 1, 2020

There are a few Options structs, which are basically the deserialized form the of the paths query string:

$ rg "TryFrom<&'a str> for" http/src/
http/src/v0/block/options.rs
14:impl<'a> TryFrom<&'a str> for RmOptions {

http/src/v0/pin/add.rs
55:impl<'a> TryFrom<&'a str> for AddRequest {

http/src/v0/refs/options.rs
42:impl<'a> TryFrom<&'a str> for RefsOptions {

http/src/v0/pin.rs
34:impl<'a> TryFrom<&'a str> for ListRequest {

These needed to be added because the plain serde_urlencoded at least did not support at the time deserializing for example this:

#[derive(Debug)]
pub struct AddRequest {
    arg: Vec<StringSerialized<Cid>>,
    recursive: bool,
    progress: bool,
}

This might be a limitation of serde "object model" or I just failed to use the library. Writing the TryFrom conversions seemed fast and flexible enough. If this arg: Vec<FromStr> member cannot be supported with serde_urlencoded we should probably just skip the particular field, and manually parse only the arg value. The best outcome of this would be a single custom filter for deserializing these "special" kinds of "options". Right now it would seem that each of these "special options" needs a custom filter creating method as well.

See for previous attempts: https://github.com/rs-ipfs/rust-ipfs/pull/349/files#r480903618

@koivunej
Copy link
Collaborator Author

koivunej commented Sep 2, 2020

Also very likely that this issue comes from me misunderstanding how should serde_urlencoded be used, feel free to fix in other ways as well 👍! Minimizing boilerplate and thus LOC needed per request representation (such as AddRequest above) is key.

@koivunej koivunej mentioned this issue Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant