Crates.io | qsocket |
lib.rs | qsocket |
version | 0.1.3 |
source | src |
created_at | 2023-03-12 12:46:10.515408 |
updated_at | 2023-10-25 16:13:41.941975 |
description | QSocket library. |
homepage | |
repository | https://github.com/qsocket/qsocket-rs |
max_upload_size | |
id | 808013 |
size | 35,713 |
Rust library for qsocket...
Usage is really simple, qsocket_rs::new
function simply creates a new quantum socket with given secret, it includes all the functions of standard std::net::TcpStream
sockets and also implements io::Read/Write
. After creating a socket you need to dial the QSRN network by calling qsocket_rs::Dial*
functions. Simple example below...
use qsocket;
/// Creates a new quantum socket instance.
///
/// `secret` value can be considered as the password for the QSocket connection,
/// It will be used for generating a 128bit unique identifier (UID) for the connection.
let mut qsock = qsocket::QSocket::new("my-secret", true);
/// Opens a TLS connection to the QSRN.
///
/// If the `verify_cert` parameter is true,
/// after establishing a TLS connection with the QSRN gate server,
/// the TLS certificate fingerprint will be validated with the hardcoded certificate fingerprint value `QSRN_CERT_FINGERPRINT`.
///
/// If the connection fails due to network related errors,
/// function will return the corresponding error, in the case of
/// QSRN related errors the function will return one the ERR_KNOCK_* errors.
if let Err(e) = qsock.dial() {
panic!("{}", e);
}
After dialing the QSRN, socket is ready for read/write operations.