uDSN
A quick little DSN parser that can give you a nice looking URI connection string on the other side:
use ;
let dsn = DSNnew
.protocol, // protocol
.username, // username
.password, // password
.resource, // uri or localpath
.host // convenience shortcut for .resource(Resource::URI...
.path // convenience shortcut for .resourde(Resource::Path...
.port, // port
.database, // dbname
.params;
dsn.to_string == "postgresql://localhost/db?sslmode=verify-full&connect_timeout=10";
/* OR, parse and modify an existing */
let dsn = DSNparse;
dsn.username = Some;
dsn.password = Some;
dsn.to_string == "postgresql://user:pass@localhost/db?sslmode=verify-full&connect_timeout=10";
/* as a bonus you can also use the percent encoder/decoder */
use ;
percent_encode == "%2f...";
percent_decode == "/...";
Motivation
The motiviation for writing this module is that other DSN modules had various bugs, dependencies, or other weirdness. The most common being that odd characters would show up when using parameters (or no parameters) and upon looking at the tests, they tested the one use case they needed the module for. Or, they provided no documentation/examples.
So, here we are.