All Projects → Peltoche → Ical Rs

Peltoche / Ical Rs

Licence: apache-2.0
Rust parser for ics (rfc5545) and vcard (rfc6350)

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Ical Rs

Lang C
Lightweight C parser for Rust
Stars: ✭ 77 (+67.39%)
Mutual labels:  parser, rust-library
Serd
A lightweight C library for RDF syntax
Stars: ✭ 43 (-6.52%)
Mutual labels:  parser
Parson
Lightweight JSON library written in C.
Stars: ✭ 965 (+1997.83%)
Mutual labels:  parser
Goawk
A POSIX-compliant AWK interpreter written in Go
Stars: ✭ 995 (+2063.04%)
Mutual labels:  parser
Photon
⚡ Rust/WebAssembly image processing library
Stars: ✭ 963 (+1993.48%)
Mutual labels:  rust-library
Logos
Create ridiculously fast Lexers
Stars: ✭ 1,001 (+2076.09%)
Mutual labels:  parser
Bookmark Parser
Find and parse Firefox/Chrome bookmark HTML and jsonlz4 file into useable JSON object or export as JSON file.
Stars: ✭ 31 (-32.61%)
Mutual labels:  parser
Dtparse
A dateutil-compatible timestamp parser for Rust
Stars: ✭ 45 (-2.17%)
Mutual labels:  rust-library
Run script
Run shell scripts in rust.
Stars: ✭ 42 (-8.7%)
Mutual labels:  rust-library
Reqray
Log call tree summaries after each request for rust programs instrumented with `tracing`.
Stars: ✭ 37 (-19.57%)
Mutual labels:  rust-library
Google Libphonenumber
The up-to-date and reliable Google's libphonenumber package for node.js.
Stars: ✭ 984 (+2039.13%)
Mutual labels:  parser
Arccstr
Thread-safe, reference-counted null-terminated immutable Rust strings.
Stars: ✭ 34 (-26.09%)
Mutual labels:  rust-library
Configparser
Config ini file parser in Go
Stars: ✭ 40 (-13.04%)
Mutual labels:  parser
Substitution Schedule Parser
Java library for parsing schools' substitution schedules. Supports multiple different systems mainly used in the German-speaking countries, including Untis, svPlan, and DAVINCI
Stars: ✭ 33 (-28.26%)
Mutual labels:  parser
Edn Data
EDN parser and generator that works with plain JS data, with support for TS and node streams
Stars: ✭ 44 (-4.35%)
Mutual labels:  parser
Django Precise Bbcode
A Django application for parsing, displaying and editing BBCodes-based text contents.
Stars: ✭ 31 (-32.61%)
Mutual labels:  parser
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-21.74%)
Mutual labels:  parser
Rocket
NetDisk in command line.
Stars: ✭ 40 (-13.04%)
Mutual labels:  parser
Lambda calculus
A simple, zero-dependency implementation of the untyped lambda calculus in Safe Rust
Stars: ✭ 46 (+0%)
Mutual labels:  rust-library
Fast Xml Parser
Validate XML, Parse XML to JS/JSON and vise versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback
Stars: ✭ 1,021 (+2119.57%)
Mutual labels:  parser

license Build Status Latest version Documentation

ical-rs

This library parse the ICalendar format defined in RFC5545, as well asl similar formats like VCard.

There are probably some issues to be taken care of, but the library should work for most cases. If you like to help out and would like to discuss any API changes, please contact me or create an issue.

The initial goal was to make a port from the ical.js library in JavaScript and many code/algorithms was taken from it but in order to but more 'Rusty' a complete rewrite have been made.

Documentation

Installing

Put this in your Cargo.toml:

[dependencies]
ical = "0.7.*"

Overview

There is several ways to use Ical depending on the level of parsing you want. Some new wrapper/formater could appeare in the next releases.

By default all the features are included but you can choose to include in you project only the needed ones.

Warning

The parsers (PropertyParser / IcalParser) only parse the content and set to uppercase the case-insensitive fields. No checks are made on the fields validity.

IcalParser / VcardParser

Wrap the result of the PropertyParser into components.

Each component can contains properties (ie: Property) or sub-components.

  • The IcalParser return IcalCalendar
  • The VcardParser return VcardContact

Cargo.toml:

[dependencies.ical]
version = "0.7.*"
default-features = false
features = ["ical", "vcard"]

Code:

extern crate ical;

use std::io::BufReader;
use std::fs::File;

fn main() {
    let buf = BufReader::new(File::open("/tmp/component.ics")
        .unwrap());

    let reader = ical::IcalParser::new(buf);

    for line in reader {
        println!("{:?}", line);
    }
}

Output:

IcalCalendar {
  properties: [],
  events: [
    IcalEvent {
      properties: [ Property { ... }, ... ],
      alarms: [
        IcalAlarm {
          properties: [ Property { ... } ]
        }
      ]
    }
  ],
  alarms: [],
  todos: [],
  journals: [],
  free_busys: [],
  timezones: []
}

PropertyParser

Parse the result of LineReader into three parts:

  • The name of the line attribute formated in uppercase.
  • A vector of (key/value) tuple for the parameters. The key is formatted in uppercase and the value is untouched.
  • The value stay untouched.

It work for both the Vcard and Ical format.

Example:

Cargo.toml:

[dependencies.ical]
version = "0.5.*"
default-features = false
features = ["property"]

Code:

extern crate ical;

use std::io::BufReader;
use std::fs::File;

fn main() {
    let buf = BufReader::new(File::open("/tmp/component.ics")
        .unwrap());

    let reader = ical::PropertyParser::from_reader(buf);

    for line in reader {
        println!("{:?}", line);
    }
}

Input -> Output:

begin:VCALENDAR                           Ok(Property { name: "BEGIN", params: None, value: Some("VCALENDAR") })
ATTENDEE;cn=FooBar:mailto:[email protected]    ->  Ok(Property { name: "ATTENDEE", params: Some([("CN", "FooBar")]), value: Some("mailto:[email protected]") })
DESCRIPTION:                              Ok(Property { name: "DESCRIPTION": params: None, value: None })
END:VCALENDAR                             Ok(Property { name: "END", params: None, value: Some("VCALENDAR") })

LineReader

This is a very low level parser. It clean the empty lines and unfold them.

It work for both the Vcard and Ical format.

Example:

Cargo.toml:

[dependencies.ical]
version = "0.5.*"
default-features = false
features = ["line"]

Code:

extern crate ical;

use std::io::BufReader;
use std::fs::File;

fn main() {
    let buf = BufReader::new(File::open("/tmp/component.ics")
        .unwrap());

    let reader = ical::LineReader::new(buf);

    for line in reader {
        println!("{}", line);
    }
}

Input -> Output:

BEGIN:VCALENDAR        Line 0: BEGIN:VCALENDAR
BEGIN:VEVENT           Line 1: BEGIN:VEVENT
SUMMARY:foo and   ->   Line 3: SUMMARY:foo andbar
 bar
END:VEVENT             Line 4: END:VEVENT
END:VCALENDAR          Line 5: END:VCALENDAR
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].