I'm using that function to connect to my postgres database and it works.
But I'd like to define my own function, that will return a connection using my connection parameters and possibly some other options.
How can I transparently use the same type as the original function, or use a shorter name for that type? I don't see if the sqlx team have given an alias to that type that we could use. How could I find out if there's a shorter name for that type?
Well, actually this is not possible to do that, since Self is supposed to refer to a type, and Error is not defined. I guess I can replace Self with the type on which the function was defined. But then I also have to go look for what kind of Error type is used. This seems time consuming.
It's not the first time I stumble upon that problem. Do you really have to reverse engineer the code of every function you want to use the output type of?
Edit: just saw your addition about BoxFuture. I don't understand it but I will look into it.
I knew Error had to be defined somewhere, but it's not clear where at first sight.
sqlx is just an example. I've stumbled upon this problem with other libraries where they define different types of errors and you have to browse through a lot of code and documentation to find out.
I want to check if there's something I'm missing, if there's an easier way to proceed.
No, there isn't. It would be better if all crates provided a type alias for their long types, but if they don't then you have to figure out the type. When creating crates, we should keep this in mind.