Repository navigation
Server: require State to be Clone - #644
Conversation
ab7e54d to
da703eb
Compare
|
I was on the edge about it, but i should have said in my OP: "Is non-Arc Clone" actually what a user would expect?" I'm not sure it is personally? Like, your state will not actually be shared between anything at all if it's not an |
I think so; this is not an uncommon thing to provide, and think it's entirely reasonable thing to allow people to implement. Certain performance sensitive applications may actually want this degree of control, and empowering them to implement this is useful. For example: you could imagine someone only has |
da703eb to
77b6a7e
Compare
Alternative to http-rs#642 This approach is more flexible but requires the user ensure that their state implements/derives `Clone`, or is wrapped in an `Arc`. Co-authored-by: Jacob Rothstein <hi@jbr.me>
77b6a7e to
50bc628
Compare
|
Updated as per suggestions. 😄 |
jbr
left a comment
There was a problem hiding this comment.
lgtm! my only nit is that since the examples are didactic, we might want to set an example of doing
// examples/upload.rs
type State = Arc<TempDir>;
/*snip*/
.put(|req: Request<State>| async move {or create a State struct, like https://github.com/jbr/tide-example/blob/master/src/main.rs#L7-L19.
|
Updated that example... i think there is a bit more work to do on the examples more generally outside of this PR. |
Alternative to
#642
This approach is more flexible but requires the user ensure that their
state implements/derives
Clone, or is wrapped in anArc.Co-authored-by: Jacob Rothstein hi@jbr.me
Notably while this has less new API surface, this requires more from user code.