Skip to content
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

Re-export bytes crate? #61

Open
0x6273 opened this issue Aug 1, 2020 · 3 comments
Open

Re-export bytes crate? #61

0x6273 opened this issue Aug 1, 2020 · 3 comments

Comments

@0x6273
Copy link

0x6273 commented Aug 1, 2020

Should the bytes crate be re-exported, since the Bytes type is used in public api? Currently, users have to add bytes as a dependency in their Cargo.toml, and match the version so that the types are the same. See Tokio tutorial "Add bytes dependency" secton for an example of what I mean.

@Darksonn
Copy link
Collaborator

Darksonn commented Aug 1, 2020

There are lots of crates with bytes in the public api that don't reexport it. Is there any particular reason it is more important for mini-redis?

@0x6273
Copy link
Author

0x6273 commented Aug 1, 2020

I think the main reason is ease of use. Figuring out what version of bytes is required and adding it as a separate dependency is an extra hurdle when using mini-redis. It's also generally considered to be best practice to re-export crates that are needed to use the public api. Is there any reason we don't want to do this?

@Darksonn
Copy link
Collaborator

Darksonn commented Aug 2, 2020

You say it is generally considered to be best practice, but I've never heard of it before, and I'm certainly not new to Rust.

In any case, I think it's fine to have people add the dependency. One of the things the tutorial should teach is the ecosystem you will be using when writing networking applications, and bytes is an integral part of that ecosystem, which you will almost certainly need to import in your own networking projects.

On the other hand, mini-redis is an incomplete example of idiomatic code, and shouldn't generally be used in your own projects. I don't want to introduce any confusion about whether bytes is something you should be using, and I think importing it through mini-redis could introduce such confusion, precisely because you aren't supposed to use mini-redis in real code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants