Skip to content

Error starting listeners with ListenerOptions::default() autocompletion #454

@oooo-ps

Description

@oooo-ps

I'm trying to init the listener with the following options (from arguments)

let session = librqbit::Session::new_with_opts(
    match preload {
        Some(ref p) => p.path(),
        None => PathBuf::new(),
    },
    SessionOptions {
        listen: Some(match config.listen {
            Some(l) => ListenerOptions {
                listen_addr: std::net::SocketAddr::from_str(&l)?,
                enable_upnp_port_forwarding: config.listen_upnp,
                ..ListenerOptions::default()
            },
            None => ListenerOptions {
                enable_upnp_port_forwarding: config.listen_upnp,
                ..ListenerOptions::default()
            },
        }),
...

In this case, when the listen_addr is not provided (None) I have following error:

Error: error starting listeners

Caused by:
    you must set the listen port explicitly

The ..ListenerOptions::default() should autocomplete default values, or that's not yet implemented and autoinit works only when the entire listen member is None?

I would like to return None but on example above I have enable_upnp_port_forwarding handler, so can't simply return the None for entire struct. As the solution, I think we can make listen_addr accepting None values, or maybe make it as optional array, for multi-binding ability.

  • also, thoughts about the None value for the first librqbit::Session::new_with_opts argument (PathBuf) - I provide empty path there, but it could be None instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions