We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
factory
pub fn connect<U, F, H>(url: U, factory: F) -> Result<()> where U: Borrow<str>, F: FnMut(Sender) -> H, H: Handler,
This is the signature of ws::connect. A ws::Handler trait object should be returned by F. I have the following implementations of ws::Handler.
struct A { ... } impl ws::Handler for A {} struct B { ... } impl ws::Handler for B {} fn new_ws(t: &String) -> Box<dyn ws::Handler> { match t { "A" => Box::new(A { ... }), "B" => Box::new(B { ... }), &_ => unimplemented!(), } }
How can I use new_ws in ws::connect as below?
ws::connect(URL, |sender| { new_ws("A") }).unwrap_or_else(|err| { error!("websocket error: {:?}", err); })
The error:
expected an `Fn<(ws::message::Message,)>` closure, found `dyn ws::handler::Handler
Thanks!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This is the signature of ws::connect. A ws::Handler trait object should be returned by F.
I have the following implementations of ws::Handler.
How can I use new_ws in ws::connect as below?
The error:
expected an `Fn<(ws::message::Message,)>` closure, found `dyn ws::handler::Handler
Thanks!
The text was updated successfully, but these errors were encountered: