1 unstable release

0.0.1 Feb 17, 2022

#19 in #cas

MIT license

43KB
569 lines

neust

CI Docs Build Latest Version

Documentation

See https://docs.rs/neust.

License

MIT License.


lib.rs:

neust

NEU CAS binding for Rust.

Explanation: Endpoints

See documentation for endpoints.

Examples

For binary program examples, see neust/examples.

Query username using token

use neust::{Session, auth};

let token = auth::Token::new("your_token");
let session = Session::new();
let status = session.login(&token).await?;
let username = status.get_username();

Access intranet service via WebVPN

Should enable feature: webvpn.

use neust::{Session, auth, webvpn};

let credential = auth::Credential::new("username", "password");
let session = Session::new();
if !session.login(&credential).await?.is_active()
    || !session.login_via_webvpn(&credential).await?.is_active() {
    panic!("fail");
}
let client = session.client();
let request = client
    .get(webvpn::encrypt_url(
        "http://219.216.96.4/eams/teach/grade/course/person!search.action?semesterId=0",
    ))
    .build()?;
let response = client.execute(request).await?;

Use Wechat to login

Should enable feature: wechat.

use neust::{Session, auth};
use tokio::time::{sleep, Duration};

let wechat = auth::Wechat::default();
let session = Session::new();

sleep(Duration::from_secs(10)).await;

let status = session.login(&wechat).await?;
let username = status.get_username();

Optional Features

  • webvpn: supports for WebVPN endpoint.
  • wechat: supports for authorization by Wechat.
  • native-tls (enabled by default): Enables TLS functionality provided by native-tls.
  • rustls-tls: Enables TLS functionality provided by rustls.
  • json: Provides serialization and deserialization for JSON bodies.

Dependencies

~7–24MB
~307K SLoC