ferristseng / rust-ipfs-api

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

Add an interface to specify --timeout, --offline, --cid-ver, ... #65

Closed jcaesar closed 2 years ago

jcaesar commented 3 years ago

This is a draft implementing #62 (cc @ec1oud). Implementing, as a feature, a way to specify --offline is fairly simple. Providing a sane interface not so much.

I've contemplated breaking it up into groups, but that'd be a rather large change, leading to something like client.with_opts(global_ops).files(files_opts).write_with_opts("foo", write_opts), but that'd be a rather large breaking change.

Anyone with any neat suggestions for an interface?

SionoiS commented 3 years ago

IMO and for my use case, some kind of builder pattern like what you propose sounds good.

ipfs add --help would become ipfs.add(None).help(); ipfs add --pin --cid-version=1 <path> becomes ipfs.add(Some(path)).pin().cid_version(1);

For global config IDK I don't use it.

Haven't looked into it much, just my 2c...

ferristseng commented 3 years ago

Could this be added now that I've restructured the repo? This fell off my radar, but I think it would be a good change. Apologies!

jcaesar commented 2 years ago

Argh, I accidentally the PR. Yes, it can be added, but things got a bit more awkward, I think. I'll open a new PR soon.