ok, time to rubber duck twitter I have a "readable storage" trait that takes a name of a package and returns None or Some(AsyncBufRead). at my Tide handler level, this readable store is my state. My handler grabs the store, asks it for a pkg, and if we have one, streams it out.
-
Show this thread
-
so far, so good. now, because tide requires the response to be AsyncBufRead + Send + Sync, I put that requirement on my readable stores associated return types as well.
1 reply 1 retweet 2 likesShow this thread -
(I don’t think too closely about why the Response::body method requires a Sync AsyncRead param. This turns out to cause pain in my immediate future. No pun intended.)
1 reply 0 retweets 0 likesShow this thread -
Things are going fine — I have a store for reading from a remote registry using surf, and one for reading through a redis cache, all using async_std. Buoyed by this success, I start digging into S3.
1 reply 0 retweets 0 likesShow this thread -
(With a lot of help,) I muddle towards a rusoto client that makes requests using surf. This may not be the most efficient, but! I’m happy with it. I wire it into a store. The s3 client returns responses with a ByteStream. Not a big problem — it has a method “into_async_read()”.
1 reply 0 retweets 1 likeShow this thread -
This method returns “impl tokio::io::AsyncRead+Send”, leading to my first q — because I have to specify my stores’ associated return type, I need to Box it into a trait object. (I think! I could be wrong!) Mischief managed, casting the Box works. Yay! However, ...
1 reply 0 retweets 0 likesShow this thread -
The mismatch between the Response (which needs a Send+Sync AsyncBufRead) and S3 (which returns an AsyncRead+Send, not Sync) means the handler can’t use my S3 store. Heck.
1 reply 0 retweets 1 likeShow this thread -
So, I have questions: why does the Tide response body need to be Sync? Why isn’t the S3 payload Sync? Can I glue this together, somehow?
2 replies 0 retweets 2 likesShow this thread
The Tide Response body needs to be sync because else borrows over async bounds aren't possible. Surf didn't used to have Sync in the bound initially (my design) and folks ran into limitations almost immediately.
-
-
Replying to @yoshuawuyts
A-ha — I think I ran into this a few months ago, when returning a surf response from a tide handler would generate a compiler message about Sync not being satisfied.
0 replies 0 retweets 2 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.