rust-jack icon indicating copy to clipboard operation
rust-jack copied to clipboard

Make ProcessCallbacks struct public

Open Davvos11 opened this issue 2 months ago • 1 comments

Changes:

Made ProcessCallbacks public in lib.rs.

Why?

When creating an AsyncClient using client.activate_async and using a handler with state, the ProcessCallbacks type is needed if you want to annotate the type of the AsyncClient

For example:

fn some_function(
) -> anyhow::Result<AsyncClient<Notifications, ClosureProcessHandler<State, ProcessCallbacks<impl FnMut(&mut State, &Client, &ProcessScope) -> Control, impl FnMut(&mut State, &Client, Frames) -> Control>>>> {
    let process_callback = move |state: &mut State, client: &Client, ps: &ProcessScope| -> Control {
        Control::Continue
    };
    let buffer_callback = |state: &mut State, client: &Client, len: Frames| -> Control {
        Control::Continue
    };

    let handler = ClosureProcessHandler::with_state(Jack::default(), process_callback, buffer_callback);
    let active_client = client.activate_async(notifications, handler)?;

    Ok(active_client)
}

Davvos11 avatar Dec 03 '25 20:12 Davvos11

I found that I can also type the client using impl ProcessHandler to avoid this issue:

fn some_function() -> anyhow::Result<AsyncClient<Notifications, impl ProcessHandler> {

Davvos11 avatar Dec 03 '25 20:12 Davvos11