hummingly / ics

A Rust library for creating iCalendar files as specified in RFC5545 and RFC7986
Other
30 stars 3 forks source link

Version 0.5 Property Constructor API [Types] #12

Closed hummingly closed 3 years ago

hummingly commented 4 years ago

Property builder types use defined value types as defined.

Closes #11 and #10 .

hummingly commented 4 years ago

Splitting the PR would allow to push a new version with numeric value support.

This requires a few things.

enum IcsValue {
    Integer(i32),
    Float(f32),
    Text(Cow<'a, str>),
     // Non-exhaustive pattern
}
hummingly commented 4 years ago

After playing around with the above strategy it would be better to keep Property as is and instead create a writer. This means the builder types would implement a trait instead and this would be written immediately.

struct IcsWriter {..}

impl IcsWriter {
    fn write(property: PropertyWrite) {
        write!(...)
    }
}

trait PropertyWrite {
    fn name() -> impl Display;
    fn value() -> impl Display;
    fn parameters() -> impl Iterator<K, V>
}

However, version 0.5 should add first the type constructors.

hummingly commented 3 years ago

I will keep this branch as reference for the writer-api.