Initialize tarpc listener with custom variable for use in functions
MohenjoDaro opened this issue · 1 comments
MohenjoDaro commented
I have a need to use a variable (connection to a database) inside the tarpc listener functions. Is there a way to pass a variable/reference to those functions (likely on setup)? Or would this need to be done with a wrapper struct or global?
Hopefully my question is clear enough, I'm not very good with terms
MohenjoDaro commented
Ah, found the solution.
pub struct RpcStruct(pub SocketAddr, pub VarType);
Changing the VarType to whatever lets you use self.1
in the impl functions