I'm working on embedding actix-web into a binding library. I would like to declare a HttpServer
within a struct so that I can easily call .start()
and .system_exit()
. From my very basic reading of the source code it's already implemented as a struct with two dependencies: <H, F>
. It also comes with a factory to instantiate itself.
If I'm understanding this correctly, then I would have to implement the HttpServer
as a dependency in my new struct and add my own characteristics within it. My previous thought was to create a new struct and just declare HttpServer
as a property within it. That seemed troublesome with the generics that needed to be declared within it.
What I've come up with so far is:
struct CustomServer<T> {
srv: T,
}
impl<T> CustomServer<T>
where
T: HttpServer,
{
fn init() {
self.srv = HttpServer::new(|| App /* etc. */)
}
}
I'm not sure if I'm grasping at straws or in the right direction.
The question is: how should/can I go about defining a struct that has HttpServer and it's functions accessible in my struct?