Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Topology struct? #32

Open
Be-ing opened this issue Dec 12, 2022 · 0 comments
Open

Topology struct? #32

Be-ing opened this issue Dec 12, 2022 · 0 comments

Comments

@Be-ing
Copy link
Contributor

Be-ing commented Dec 12, 2022

I'm wondering if it could be helpful to add a struct like

struct Topology {
    pub channels: usize,
    pub frames: usize,
}

to pass to Buf::with_topology and ResizableBuf::resize_topology. When writing these functions, it is easy to mix up the channels and frames arguments because both are usizes. I have to refer to the documentation to ensure that I'm calling them correctly. Currently, calls to these look like:

let buffer = Sequential::with_topology(2, 256);

There would be less room for confusion like this:

let buffer = Sequential::with_topology(Topology { channels: 2, frames: 256 });

or

let topology = Topology { channels: 2, frames: 256 };
let buffer = sequential::with_topology(topology);

An alternative solution could be adding newtypes for frames and/or channels.

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

No branches or pull requests

1 participant