jpopesculian / twitter-v2-rs

Rust bindings for Twitter API v2
https://docs.rs/twitter-v2/latest
102 stars 28 forks source link

request builder `send` methods use `&self` argument #10

Open db48x opened 2 years ago

db48x commented 2 years ago

I’m surprised to discover this, because usually finalizing a builder consumes the builder and returns a wholly new object. As currently written, the builder cannot be a temporary; it has to be kept around as long as the request and response are so that they can refer to it.

Was this a deliberate choice? If so, can you document the reasoning for it? If not, can we change the send (and stream) methods to take Self instead?

jpopesculian commented 2 years ago

I see what you mean :disappointed: Unfortunately I don't think it will be that easy because to really decouple everything we need to make the TwitterApi::send function non-lifetime dependent and at the moment, this is hooked into Authorization to get headers which allows for a Future response due to oauth2 refreshing. Unfortunately the oauth2 refreshing stuff also has some lifetime issues which I've raised here https://github.com/ramosbugs/oauth2-rs/issues/179. I'll see if I can help them with that and get this moving towards that direction