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 Buf and BufMut directly on wrapped dynamic types instead of providing wrappers? #31

Open
udoprog opened this issue Dec 12, 2022 · 3 comments
Labels
question Further information is requested

Comments

@udoprog
Copy link
Owner

udoprog commented Dec 12, 2022

Two libraries I'm using quite frequently are bstr, and bytes (who's naming convention is borrowed here), and one of their decisions is to implement an [extension trait directly on types instead of solely requiring a wrapper like the wrap module:

This is an option worth exploring for the audio crate, and maybe one to seriously consider. Because it would preempt questions such as the need to export the wrap module from crates, making it easier to use primitive Rust types directly meaning users might not even need to depend on the audio crate to use the library. Unless they have a specific reason like using audio crate-specific buffers.

CC: @Be-ing

@udoprog udoprog added the question Further information is requested label Dec 12, 2022
@udoprog
Copy link
Owner Author

udoprog commented Dec 12, 2022

Note that wrap could still be used by downstreams to wrap plain slices into interleaved or planar slices since these need to be provided a channel length. This would only really serve to get rid of wrap::Dynamic.

@udoprog udoprog changed the title Implement Buf and BufMut directly on wrapped types instead of providing wrappers? Implement Buf and BufMut directly on wrapped dynamic types instead of providing wrappers? Dec 12, 2022
@Be-ing
Copy link
Contributor

Be-ing commented Dec 12, 2022

This would only really serve to get rid of wrap::Dynamic.

That would be nice. However, if we decide to make a uniform channel length an invariant of the Buf trait (#30), implementing Buf/BufMut directly on standard library types would remove the opportunity to check that when constructing a wrapper.

@udoprog
Copy link
Owner Author

udoprog commented Dec 12, 2022

Would it? Such a wrapper could implement ExactSizeBuf.

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

No branches or pull requests

2 participants