mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 09:18:22 +00:00
Update ical-rs
This commit is contained in:
@@ -11,7 +11,6 @@ use rustical_ical::CalendarObjectType;
|
||||
use rustical_store::{
|
||||
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
||||
};
|
||||
use std::io::BufReader;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(resource_service))]
|
||||
@@ -26,7 +25,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = ical::IcalParser::new(BufReader::new(body.as_bytes()));
|
||||
let parser = ical::IcalParser::from_slice(body.as_bytes());
|
||||
let mut cal = parser
|
||||
.expect_one()
|
||||
.map_err(rustical_ical::Error::ParserError)?
|
||||
|
||||
@@ -87,7 +87,7 @@ pub async fn route_mkcalendar<C: CalendarStore, S: SubscriptionStore>(
|
||||
Some(tzid)
|
||||
} else if let Some(tz) = request.calendar_timezone {
|
||||
// TODO: Proper error (calendar-timezone precondition)
|
||||
let calendar = IcalParser::new(tz.as_bytes())
|
||||
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||
.next()
|
||||
.ok_or_else(|| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?
|
||||
.map_err(|_| rustical_dav::Error::BadRequest("Error parsing timezone".to_owned()))?;
|
||||
|
||||
@@ -202,7 +202,7 @@ impl Resource for CalendarResource {
|
||||
CalendarProp::CalendarTimezone(timezone) => {
|
||||
if let Some(tz) = timezone {
|
||||
// TODO: Proper error (calendar-timezone precondition)
|
||||
let calendar = IcalParser::new(tz.as_bytes())
|
||||
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
rustical_dav::Error::BadRequest(
|
||||
|
||||
@@ -10,7 +10,6 @@ use ical::{
|
||||
property::ContentLine,
|
||||
};
|
||||
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
|
||||
use std::io::BufReader;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(resource_service))]
|
||||
@@ -24,7 +23,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = vcard::VcardParser::new(BufReader::new(body.as_bytes()));
|
||||
let parser = vcard::VcardParser::from_slice(body.as_bytes());
|
||||
|
||||
let mut objects = vec![];
|
||||
for res in parser {
|
||||
|
||||
@@ -14,8 +14,8 @@ use ical::parser::{
|
||||
use ical::property::ContentLine;
|
||||
use ical::types::{CalDate, PartialDate};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
use std::{collections::HashMap, io::BufReader};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddressObject {
|
||||
@@ -32,7 +32,7 @@ impl From<VcardContact> for AddressObject {
|
||||
|
||||
impl AddressObject {
|
||||
pub fn from_vcf(vcf: String) -> Result<Self, Error> {
|
||||
let parser = vcard::VcardParser::new(BufReader::new(vcf.as_bytes()));
|
||||
let parser = vcard::VcardParser::from_slice(vcf.as_bytes());
|
||||
let vcard = parser.expect_one()?;
|
||||
Ok(Self { vcf, vcard })
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::Error;
|
||||
use derive_more::Display;
|
||||
use ical::IcalObjectParser;
|
||||
use ical::component::CalendarInnerData;
|
||||
use ical::component::IcalCalendarObject;
|
||||
use ical::generator::Emitter;
|
||||
use ical::parser::ComponentParser;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -69,7 +69,7 @@ pub struct CalendarObject {
|
||||
|
||||
impl CalendarObject {
|
||||
pub fn from_ics(ics: String) -> Result<Self, Error> {
|
||||
let parser: ComponentParser<_, IcalCalendarObject> = ComponentParser::new(ics.as_bytes());
|
||||
let parser = IcalObjectParser::from_slice(ics.as_bytes());
|
||||
let inner = parser.expect_one()?;
|
||||
|
||||
Ok(Self { inner, ics })
|
||||
|
||||
Reference in New Issue
Block a user