Expand description
a simple library for logging into USTC CAS System.
§Usage
All you should do is call get_ticket. The function param service_url can
be found from browser’s address bar when logging into CAS by hand. The returned ticket value
can be used for further authentication specific to websites.
ustc_cas::get_ticket is an async function and requires a async runtime
to execute. While ustc_cas::blocking::get_ticket,
enabled by blocking feature, can not be used in an aysnc runtime.
It with block the current thread before returning.
§Example
use tokio::runtime::Builder;
let runtime = Builder::new_current_thread()
.enable_io()
.enable_time()
.build()
.unwrap();
let result = runtime.block_on(ustc_cas::get_ticket(
"PB00000000",
"12345678",
"https://jw.ustc.edu.cn/ucas-sso/login",
));
match result {
Ok(s) => {
println!("ticket: {s}");
},
Err(e) => {
println!("Error: {e}");
}
}§Features
validate-code: Validate code recognition usingimageandbytescrate.get_ticketfunction will panic if this feature is disabled but validate code is requested. Enabled by default.blocking: provide blocking version ofget_ticketfunction.native-tls: Use system tls library. Enabled by default.rustls-tls: Use rustls for tls functionality.
Modules§
- blocking
- provide blocking version of
get_ticket
Structs§
- CasError
- The error type.
Enums§
- Error
Kind - The error kind used by
CasError
Functions§
- get_
ticket - log into USTC CAS System and get ticket value.