Skip to content

Prevent tauri::ipc::Channel outside function arguments and results #198

Description

@oscartbeaumont

I don't think it's valid so we should detect and error.

The current prototype I had is the following:

// TODO: This only works if no functions use `Channel` which isn't really desired.
// TODO: I wonder if this error should be in Specta???
// TODO: Test this works
// if !is_channel_used
//     && let Some(ndt) = builder.types.into_unsorted_iter().find(|ndt| {
//         ndt.name() == "TAURI_CHANNEL" && ndt.module_path().starts_with("tauri::")
//     })
// {
//     return Err(Error::Framework(
//         format!("Detected invalid usage of `tauri::ipc::Channel` in type '{}' defined in {} which is not valid! It can only be an argument or result of a Tauri command.", ndt.name(), ndt.module_path()).into()
//     ));
// }

but this overlooks the fact that the channel can be included in a struct & the channel import can be used in a function and it would let it through. It needs to be smarter.

Can a Tauri channel be included in an event??? Add that into detection code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions