Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ nom-language = "0.1.0"
base64 = "0.22"
hex = "0.4"
lazy_static = "1.4"
anyhow = "1"

# builder
time = "0.3"
Expand Down
7 changes: 4 additions & 3 deletions src/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::{AetoliaError, AetoliaResult};
use crate::model::property::Duration;
use std::cmp::Ordering;
use std::ops::{Add, Sub};
Expand Down Expand Up @@ -241,7 +242,7 @@ impl From<(time::Date, Option<time::Time>, bool)> for CalendarDateTime {
}

impl CalendarDateTime {
pub fn add(&self, duration: &Duration) -> anyhow::Result<Self> {
pub fn add(&self, duration: &Duration) -> AetoliaResult<Self> {
match self.time {
Some(time) => {
// TODO otherwise you have to account for daylight changes. Not yet supported
Expand Down Expand Up @@ -362,8 +363,8 @@ impl CalendarDateTime {
utc: self.utc,
})
} else {
Err(anyhow::anyhow!(
"Duration is a time, but the calendar date time is just a date"
Err(AetoliaError::other(
"Duration is a time, but the calendar date time is just a date",
))
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/convert.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::error::AetoliaResult;

mod component;
mod object;
mod param;
Expand All @@ -7,7 +9,7 @@ mod property;
pub trait ToModel {
type Model;

fn to_model(&self) -> anyhow::Result<Self::Model>;
fn to_model(&self) -> AetoliaResult<Self::Model>;
}

impl<T> ToModel for Vec<T>
Expand All @@ -16,7 +18,7 @@ where
{
type Model = Vec<T::Model>;

fn to_model(&self) -> anyhow::Result<Self::Model> {
fn to_model(&self) -> AetoliaResult<Self::Model> {
self.iter().map(ToModel::to_model).collect()
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/convert/component.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::convert::{convert_string, ToModel};
use crate::error::AetoliaResult;
use crate::model::component::{
AlarmComponent, DaylightComponent, EventComponent, FreeBusyComponent, JournalComponent,
StandardComponent, TimeZoneComponent, ToDoComponent,
Expand All @@ -9,7 +10,7 @@ use crate::parser::types::ContentLine;
impl ToModel for crate::parser::types::CalendarComponent<'_> {
type Model = crate::model::component::CalendarComponent;

fn to_model(&self) -> anyhow::Result<Self::Model> {
fn to_model(&self) -> AetoliaResult<Self::Model> {
match self {
crate::parser::types::CalendarComponent::Event { properties, alarms } => {
let mut component = EventComponent::new();
Expand Down Expand Up @@ -145,7 +146,7 @@ impl ToModel for crate::parser::types::CalendarComponent<'_> {
fn map_unknown_lines(
lines: &Vec<ContentLine>,
component_properties: &mut Vec<ComponentProperty>,
) -> anyhow::Result<()> {
) -> AetoliaResult<()> {
for line in lines {
let m = line.to_model()?;
if m.name.starts_with("X-") || m.name.starts_with("x-") {
Expand Down
3 changes: 2 additions & 1 deletion src/convert/object.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::convert::ToModel;
use crate::error::AetoliaResult;

impl ToModel for crate::parser::types::ICalendar<'_> {
type Model = crate::model::object::ICalObject;

fn to_model(&self) -> anyhow::Result<Self::Model> {
fn to_model(&self) -> AetoliaResult<Self::Model> {
let mut calendar = crate::model::object::ICalObject::new();

calendar.properties.reserve(self.properties.len());
Expand Down
3 changes: 2 additions & 1 deletion src/convert/param.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::convert::{convert_string, ToModel};
use crate::error::AetoliaResult;
use crate::model::param::{
AlternateRepresentationParam, CalendarUserTypeParam, CommonNameParam, DelegatedFromParam,
DelegatedToParam, DirectoryEntryReferenceParam, EncodingParam, FormatTypeParam,
Expand All @@ -11,7 +12,7 @@ use crate::parser::types::ParamValue as ParserParam;
impl ToModel for ParserParam<'_> {
type Model = ModelParam;

fn to_model(&self) -> anyhow::Result<Self::Model> {
fn to_model(&self) -> AetoliaResult<Self::Model> {
Ok(match self {
ParserParam::AltRep { uri } => ModelParam::AltRep(AlternateRepresentationParam {
uri: convert_string(uri),
Expand Down
Loading
Loading