Expand description
§librus-rs
Rust client for Librus Synergia - the Polish school diary system.
This crate provides an async API client for accessing student grades, attendance, messages, and other data from Librus Synergia.
§Quick Start
use librus_rs::Client;
#[tokio::main]
async fn main() -> Result<(), librus_rs::Error> {
// Create client from environment variables
let mut client = Client::from_env().await?;
// Fetch grades
let grades = client.grades().await?;
for grade in grades.grades {
println!("{}: {}", grade.date, grade.grade);
}
// Fetch unread message count
let unread = client.unread_counts().await?;
println!("Unread messages: {}", unread.inbox);
Ok(())
}§Client Construction
There are three ways to create a Client:
§From Environment Variables
Reads LIBRUS_USERNAME and LIBRUS_PASSWORD from the environment:
use librus_rs::Client;
let client = Client::from_env().await?;§With Explicit Credentials
use librus_rs::Client;
let client = Client::new("username", "password").await?;§Using the Builder Pattern
use librus_rs::Client;
let client = Client::builder()
.username("username")
.password("password")
.build()
.await?;§API Overview
The client provides access to two APIs:
§Synergia API
Academic data including grades, attendance, lessons, and users.
| Method | Description |
|---|---|
Client::me() | Current user info |
Client::grades() | All grades |
Client::grade_category() | Grade category by ID |
Client::grade_comment() | Grade comment by ID |
Client::lesson() | Lesson info by ID |
Client::subject() | Subject info by ID |
Client::attendances() | All attendances |
Client::attendance_types() | Attendance types |
Client::homeworks() | All homeworks |
Client::school_notices() | School notices (announcements) |
Client::user() | User by ID |
Client::current_user() | Current user details |
§Messages API
Internal messaging system.
| Method | Description |
|---|---|
Client::unread_counts() | Unread message counts |
Client::inbox_messages() | Received messages |
Client::outbox_messages() | Sent messages |
Client::message() | Full message details |
Client::attachment() | Download attachment |
§Error Handling
All API methods return Result<T, Error>. See Error for possible error variants.
use librus_rs::{Client, Error};
let result = Client::from_env().await;
match result {
Ok(client) => println!("Authenticated successfully"),
Err(Error::MissingEnvVar(var)) => eprintln!("Missing: {}", var),
Err(Error::Authentication) => eprintln!("Invalid credentials"),
Err(e) => eprintln!("Error: {}", e),
}Structs§
- Attachment
- A file attachment in a message.
- Attendance
- A student’s attendance record for a lesson.
- Attendance
Type - A type of attendance (present, absent, late, etc.).
- Client
- An authenticated Librus API client.
- Client
Builder - Builder for creating a
Clientinstance with custom configuration. - Grade
- A student’s grade.
- Grade
Category - A grade category describing the type of assessment.
- Grade
Comment - A comment attached to a grade.
- Homework
- A homework assignment.
- Inbox
Message - A message in the inbox (received message).
- Lesson
- A lesson linking a teacher, subject, and class.
- Lesson
Subject - An academic subject.
- Me
- Current user information combining account, profile, and class.
- Message
Detail - Full message details including content and attachments.
- Outbox
Message - A message in the outbox (sent message).
- Response
Attendances - Response containing all attendances.
- Response
Attendances Type - Response containing all attendance types.
- Response
Grades - Response containing all grades.
- Response
Grades Categories - Response containing a single grade category.
- Response
Grades Comments - Response containing a single grade comment.
- Response
Homeworks - Response containing all homeworks.
- Response
Lesson - Response containing a single lesson.
- Response
Lesson Subject - Response containing a single subject.
- Response
Me - Response containing current user information.
- Response
School Notices - Response containing school notices (announcements).
- Response
User - Response containing a single user.
- School
Notice - A school notice (announcement).
- Unread
Counts - Unread message counts across all folders.
- User
- A user in the Librus system (student, teacher, or parent).
Enums§
- Error
- Errors that can occur when using the Librus API client.
Type Aliases§
- Result
- A specialized
Resulttype for librus-rs operations.