This is a toy library with which you can import Rust files over HTTPS.
Why? Because why NOT!
The library is inpired by @TsodingDaily's YouTube video
It's a great watch.
And also much more complicated than what I did for this implementation.
Add the library to your Cargo.toml.
use-https = { version = "0.1.0", git = "https://github.com/Maki325/use-https.git", tag = "0.1.0" }There are two ways to use the library, and you can of course mix and match:
- The code is wrapped into a module (and optionaly
use) - The code is not wrapped into a module (mostly meant for importing the code into a file, and then using the file as the module)
use_https::use_https! {
import cool_lib_module from "https://raw.githubusercontent.com/Maki325/use-https/master/example/example/cool_lib.rs";
}
fn main() {
cool_lib_module::say_hello();
}The code from the link is wrapped into the cool_lib_module module.
We can use exports from it with:
use_https::use_https! {
import cool_lib_module::{say_hello} from "https://raw.githubusercontent.com/Maki325/use-https/master/example/example/cool_lib.rs";
}So it would end up like this:
use_https::use_https! {
import cool_lib_module::{say_hello} from "https://raw.githubusercontent.com/Maki325/use-https/master/example/example/cool_lib.rs";
}
fn main() {
say_hello();
}Of course, you can still use all the other exports from the cool_lib_module by yourself.
In a file named test.rs
use_https::use_https! {
import "https://raw.githubusercontent.com/Maki325/use-https/master/example/example/cool_lib.rs";
}And then in the main file, we can use it like a normal module:
mod test;
fn main() {
test::say_hello();
}