-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
77b6a7e
to
50bc628
Compare
Updated as per suggestions. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 [email protected]
Notably while this has less new API surface, this requires more from user code.