Function outline_api::new
source · pub fn new<'a>(
cert_sha256: &'a str,
api_url: &'a str,
request_timeout: Duration
) -> OutlineVPN<'a>
Expand description
Creates a new OutlineVPN
client to interact with the Outline VPN Server management API.
This function initializes and configures an OutlineVPN
client with the provided parameters.
Arguments
cert_sha256
: A reference to a string representing the SHA-256 hash of the server’s certificate.api_url
: A reference to a string representing the URL of the Outline VPN server API.request_timeout_in_sec
:Duration
specifying the timeout for API requests.
Returns
Returns an OutlineVPN
client configured with the specified parameters.
Examples:
Creating an OutlineVPM API client:
use std::time::Duration;
// Reading from the `config.rs` is preferred way, see README.md at github repo
// https://github.com/sigseg5/outline-api/blob/master/README.md
let api_url = "https://example.com/secret";
let cert_sha256 = "cert_sha256_hash";
let request_timeout = Duration::from_secs(10);
let outline_vpn = outline_api::new(api_url, cert_sha256, request_timeout);
// Performing operations using the lient:
match outline_vpn.get_server_info() {
Ok(server_info) => {
println!("Server information: {}", server_info);
},
Err(err) => {
eprintln!("Error: {}", err);
}
}