Git Product home page Git Product logo

ics's People

Contributors

cxarli avatar greenfierydragon avatar hummingly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cxarli

ics's Issues

Type Checking

API

  • Quote Parameter Values automatically if they contain a COLON, SEMICOLON or COMMA
  • Escape Text automatically without needing to call escape_text
  • Replace type of value in Property and Parameter with a Value type
  • Add list method with proper field separator

Strategy to minify breakage

  • Add FromStr implementation for types, properties and parameters

Specifying Builder Types

In some cases there is only a range of values for some properties and parameters. Those could be converted to enums:

  • Parameters
    • Encoding
    • Range
    • Related
    • RSVP
  • Audio needs pub fn new(action: Action, trigger: Trigger) -> Self constructor.

Documentation and Extensive Testing

  • Currently there is no documentation on anything, nor a good example. The docs should partially point to the part in the RFC.
  • In the RFC are some examples of the components. Those should be adapted to create extensive tests for each component and added together (of course tweaked) should be one big test which can also be part of an example.
  • There should be a simple example to create an ICalendar file.

Add specification RFC7986

Property

  • NAME Property
  • REFRESH-INTERVAL Property
  • SOURCE Property
  • COLOR Property
  • IMAGE Property
  • CONFERENCE Property

Parameter

  • DISPLAY Property Parameter
  • EMAIL Property Parameter
  • FEATURE Property Parameter
  • LABEL Property Parameter

Broken feature flag

I just realized that the crate cannot be build with default features off.

  • Add test.
  • Annotate everything with flags where necessary.
  • Build script or conditional property_builder! macro.

Semantic Checks

While each property has a type, not all values make sense or are allowed.

Correctness & Completeness

  • Remove Into<Cow<str>> for Parameter enums
  • (optional) join! & join_text macro
    • It should solve the problem of adding a list of values. join_test! would use the escape_test function for each value.
    • Furthermore, it would be cool to add a formatter to format the values properly.
    • example:
      join!(("Formatter")*, (method on each value)*, &[T: impl Display])
  • list method instead of join (for parameters)
  • #[feature = "rfc7986"] #7 #8
  • (optional) linking in documentation
  • big example in README/examples folder
  • CHANGELOG for version 0.2

impl From<chrono::DateTime<Utc>> for DtStart, DtEnd, DtStamp

It would be very cool if you could do

use ics::{Event, properties::*};
use chrono::prelude::*;

let start = Utc::now();
let end = start + Duration::hours(1);

let mut event = Event::new("Some test event", start);
event.push(DtStart::new(start));
event.push(DtEnd::new(end));

I can understand it if you don't always want to include the chrono dependency for this, but a non-default feature would also be nice.

Since ical's date format does not seem very standard, it doesn't have a conversion function built-in in chrono, meaning you have to do the following yourself:

fn dt_to_ical(dt: DateTime<Utc>) -> String {
        // .format is lazy, so you have to wrap it again inside `format!` to get an actual String
	format!("{}", dt.format("%Y%m%dT%H%M%SZ"))
}
// ...
event.push(DtStart::new(dt_to_ical(start)); // etc

Given that chrono is a pretty popular crate for datetimes, this does not feel very smooth.

Rename Properties

FBTime -> FreeBusyTime
parameters::TZID -> TzID (test if it conflicts with other TzID)

Types

Simple Wrappers

  • Boolean (bool)
    • From impl
    • FromStr impl

Character Encoding

  • Binary (Cow<'b, [u8])
    • Encoding
    • Decoding (FromStr)
    • Tests
  • Text (Cow<'a, str>)
    • Encoding (Escaping Characters)
    • Decoding (FromStr)
    • Tests
  • URI (Cow<'a, str>)
    • Only plain string or Uri from hyper?
    • FromStr
  • CalAdress (URI)
    • mailto URI
    • FromStr impl

Time

  • Date
    • FromStr
  • DateTime
    • FromStr
  • Duration
    • week constructor
    • day constructor
    • time constructor
    • FromStr
  • Period
    • start constructor
    • explicit constructor
    • FromStr
  • Recur
    • builder constructor
    • FromStr
  • Time
    • FromStr impl
  • UTCOffset
    • east constructor
    • west constructor
    • FromStr

List

Some properties can take a list of values which is why the library should offer a simple Iterator based List type.

  • List
    • Single Value
    • Sequence
    • FromStr for each iCalendar type

Remove Into<Cow<str>> from parameter enums

The conversion is a bit misleading as it only converts it into the value of the parameter. Futhermore, the builder types do not implement this trait! Most importantly this "leaks" implementation details.
pub fn into(self) -> Cow<str> -> fn as_value(self) -> Cow<str>

Improve util functions

We can avoid one loop in fold_line by not clearing the whole String but just after the first 75 bytes and collect the Drain iterator into the read only slice.

/// Inside fold_line
// Getting the length before mutating the content removes the possibility of bugs
let len = content_line.len();

// drain the first 75 bytes or before if the boundary is not on a char boundary
let mut boundary = LINE_LIMIT;
// looks for the end of a UTF-8 code point
while !input.is_char_boundary(boundary) {
    boundary -= 1;
}
let input: String = content_line.drain(boundary..).collect();
// if it works it should remove the need for having to borrow input before slicing it
let input = input.as_str();
// we do not need to check if the boundary is smaller than len since fold_line is called only when the content is longer than LINE_LIMIT
content_line.push_str("\r\n ");

Furthermore, we can allocate more precisely the capacity of the output String in the escape_value_regex by doing the same as in escape_value. This is still not 100% accurate but better than allocating half when there is only one comma.

/// Inside escape_value_regex
let size = input.len() + input.chars().filter(|&c| escaped_char(c)).count();
let mut output = String::with_capacity(size);

escaped_char becomes escaped_chars and maybe a closure in at least escape_value_regex.

Parsing Ability

Editing Capabilities

This will add editing methods which makes the components in the library useful for parsing. The library itself doesn't offer parsing but this way one can implement it.

  • FromStr?
  • Add more methods for interacting with objects. Possible feature flag

    View/Search

    • pub fn contains(&self, property: &str) -> bool
    • pub fn get(&self, property: &str) -> Option<Vec<&Property>>
    • pub fn properties(&self) -> Option<Vec<&Property>>
    • pub fn components<C: Into<Component>(&self) -> Option<Vec<&C>>
    • pub fn name(&self) -> &str
    • pub fn value(&self) -> &str
    • pub fn parameters(&self) -> Option<&Parameters>

    Mutation/Editing

    • pub fn get_mut(&mut self, property: &str) -> Option<&mut Vec<Property>>
    • pub fn replace(&mut self, property: &str, index: usize, replacement_val: &str) -> Option<Property>
    • pub fn replace_first(&mut self, property: &str, replacement_val: &str) -> Option<Property>
    • pub fn replace_all(&mut self, property: &str, replacement: &[Property]) -> Option<&[Property]>

    Deletion

    • pub fn clear(&mut self)
    • pub fn remove_all(&mut self, property: &str) -> Option<Vec<&Property>>

panicked at 'byte index 76 is not a char boundary

Hello, there.
I have a issue with next_boundary function.
Could you please fix this issue?

For exmaple, change 71 line in contentline.rs
let content = "Content lines shouldn't be folded in the middle of a UTF-8 character! 老虎.";
to
let content = "Content lines shouldn't be folded in the middle of a UTF-8 character! 老 虎.";

and cargo test

---- contentline::tests::multibytes stdout ----
thread 'contentline::tests::multibytes' panicked at 'byte index 76 is not a char boundary; it is inside '虎' (bytes 74..77) of `Content lines shouldn't be folded in the middle of a UTF-8 character! 老 虎.`', src/contentline.rs:30:11
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.