ferristseng / rust-ipfs-api

IPFS HTTP client in Rust
Apache License 2.0
247 stars 68 forks source link

add_with_form #86

Closed iohzrd closed 2 years ago

ferristseng commented 3 years ago

Alright, I changed it. Lemme know what you think.

Build is still failing. Can you try this:

Can you also update ipfs-api-backend-hyper and ipfs-api-backend-actix so they are exporting Form? This would mostly be for convenience so people don't have to import any additional libraries.

iohzrd commented 2 years ago

Sorry for the delay. Also, sorry, but I'm still new to rust, and I'm not entirely sure how to accomplish what you're asking.

ferristseng commented 2 years ago

Sorry for the delay. Also, sorry, but I'm still new to rust, and I'm not entirely sure how to accomplish what you're asking.

No worries! Basically in ipfs-api-backend-hyper/src/lib.rs, you would add pub use multipart::client::multipart::Form (same with ipfs-api-backend-actix/src/lib.rs). This makes it so there isn't a need to declare a dependency on common_multipart_rfc7578, since you can import it directly from the backend library.

Then, I would update your doc test to this:

    /// ```no_run
    /// use ipfs_api::{IpfsApi, IpfsClient, Form};
    /// use common_multipart_rfc7578::client::multipart;
    /// use std::io::Cursor;
    ///
    /// #[cfg(feature = "with-builder")]
    /// let add = ipfs_api::request::Add::builder()
    ///     .wrap_with_directory(true)
    ///     .build();
    /// #[cfg(not(feature = "with-builder"))]
    /// let add = ipfs_api::request::Add {
    ///     wrap_with_directory: Some(true),
    ///     ..Default::default()
    /// };
    ///
    /// let mut form = Form::default();
    /// form.add_reader_file("path", Cursor::new(Vec::new()), "file.txt");
    ///
    /// let client = IpfsClient::default();
    /// let res = client.add_with_form(form, add);
    /// ```

Rather than import from common_multipart_rfc7578, you can import the Form directly from ipfs_api now.

iohzrd commented 2 years ago

alright, hopefully this fixes it. Thanks for the tip.