#calendar #events #oauth2 #google-calendar

gcal_rs

A blazingly fast, hand written Google calendar API in Rust

7 releases

0.1.7 Oct 16, 2024
0.1.6 Oct 13, 2024
0.1.5 Sep 29, 2024

#870 in Asynchronous

GPL-3.0 license

48KB
1K SLoC


🗓️ gcal_rs: Google Calendar API 🗓️

A blazingly fast, hand written Google calendar API in Rust.

Docs Crate License Status

UsageNotesExamplesDevelopment
Docs

Summary

This is intended to be a solution to the current state of Google Calendar API's for Rust out there currently. There are a few out there but either are for specific projects usecases or just are horribly generated.

I'm not saying this is perfect but it attempts to be better and have some solidity.

Example

use gcal::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client_id = std::env::var("GOOGLE_CLIENT_ID")?;
    let client_secret = std::env::var("GOOGLE_CLIENT_SECRET")?;

    let token = OAuth::new(client_id, client_secret, "http://localhost:5000/auth")
        .naive()
        .await?;

    let (calendar_client, event_client) = GCalClient::new(token.access)?.clients();

    let list = calendar_client
        .list(true, CalendarAccessRole::Reader)
        .await?;

    let start = Local::now();
    let end = Local::now().checked_add_signed(Duration::days(7)).unwrap();

    let mut event_list = Vec::new();
    for calendar in list {
        event_list.extend(
            event_client
                .list(calendar.id.clone(), start, end)
                .await?,
        );
    }

    println!("Events: ");
    for event in &event_list {
        println!("  - {} : {}", event.summary, event.calendar_id);
    }
}

Status

Currently working on updating documentation for each part of the code and structuring the best API.

Author

Shadorain shadorain7517@gmail.com

Original Authors

Erik Hollensbe erik+github@hollensbe.org : gcal

Dependencies

~9–21MB
~308K SLoC