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

Implement more traits for EasyBuf #120

Closed
Yamakaky opened this issue Dec 8, 2016 · 9 comments
Closed

Implement more traits for EasyBuf #120

Yamakaky opened this issue Dec 8, 2016 · 9 comments

Comments

@Yamakaky
Copy link

Yamakaky commented Dec 8, 2016

Clone, Deref, Into<Vec<u8>> would be a start.

@tailhook
Copy link
Contributor

tailhook commented Dec 8, 2016

I think also Index<..> would be cool. Because drain_to is very-limited.

@Yamakaky
Copy link
Author

Yamakaky commented Dec 8, 2016

Deref<[u8]> would be sufficient, I think?

@tailhook
Copy link
Contributor

tailhook commented Dec 8, 2016

No, I mean slicing should return EasyBuf not &[u8], because EasyBuf has a static lifetime, so can be a part of a return value of the protocol parser (and EasyBuf is specifically designed not to make a clone of the underlying data for that, it's how drait_to works)

@Yamakaky
Copy link
Author

Yamakaky commented Dec 8, 2016

Oh, yeah

@alexcrichton
Copy link
Contributor

The intention was to be very conservative for the initial iteration that we could tack on more functionality later, but I couldn't mind adding a few more common trait impls and such. I'd prefer to avoid Deref for now to avoid conflicts with the slice API, but other common traits should be good to go.

@aturon
Copy link
Contributor

aturon commented Dec 17, 2016

cc #128

manuel-woelker added a commit to manuel-woelker/tokio-core that referenced this issue Jan 22, 2017
Debug format looks like this for small resp. long buffers

EasyBuf{len=2/6 [5, 6]}
EasyBuf{len=255/255 [0, 1, 2, 3, ..., 251, 252, 253, 254]}
manuel-woelker added a commit to manuel-woelker/tokio-core that referenced this issue Feb 7, 2017
manuel-woelker added a commit to manuel-woelker/tokio-core that referenced this issue Feb 8, 2017
manuel-woelker added a commit to manuel-woelker/tokio-core that referenced this issue Feb 10, 2017
manuel-woelker added a commit to manuel-woelker/tokio-core that referenced this issue Feb 10, 2017
alexcrichton added a commit that referenced this issue Feb 11, 2017
impl Into<Vec<u8>> for EasyBuf (cf. #120)
@manuel-woelker
Copy link
Contributor

@tailhook I was looking at implementing Index for EasyBuf, with Output = EasyBuf. But it seems index
returns &Self::output. That means my naive approach - creating a new EasyBuf instance to return - won't work since it does not live long enough. Any pointers on how to proceed? Would this require IndexGet/IndexMove?

@tailhook
Copy link
Contributor

@manuel-woelker, hm, looks like we can't do that :(. The best way I can see is to have a method x.slice(a..b).

@alexcrichton
Copy link
Contributor

Done in https://github.com/alexcrichton/tokio-io, the migration of this crate will be tracked by #61

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

5 participants