diff options
Diffstat (limited to 'aero-dav')
-rw-r--r-- | aero-dav/src/calencoder.rs | 18 | ||||
-rw-r--r-- | aero-dav/src/error.rs | 19 | ||||
-rw-r--r-- | aero-dav/src/realization.rs | 4 | ||||
-rw-r--r-- | aero-dav/src/xml.rs | 6 |
4 files changed, 40 insertions, 7 deletions
diff --git a/aero-dav/src/calencoder.rs b/aero-dav/src/calencoder.rs index fff4d47..e00876d 100644 --- a/aero-dav/src/calencoder.rs +++ b/aero-dav/src/calencoder.rs @@ -393,7 +393,14 @@ impl QWrite for CompKind { for comp in many_comp.iter() { // Required: recursion in an async fn requires boxing // rustc --explain E0733 - Box::pin(comp.qwrite(xml)).await?; + // Cycle detected when computing type of ... + // For more information about this error, try `rustc --explain E0391`. + // https://github.com/rust-lang/rust/issues/78649 + #[inline(always)] + fn recurse<'a>(comp: &'a Comp, xml: &'a mut Writer<impl IWrite>) -> futures::future::BoxFuture<'a, Result<(), QError>> { + Box::pin(comp.qwrite(xml)) + } + recurse(comp, xml).await?; } Ok(()) } @@ -525,7 +532,14 @@ impl QWrite for CompFilterMatch { for comp_item in self.comp_filter.iter() { // Required: recursion in an async fn requires boxing // rustc --explain E0733 - Box::pin(comp_item.qwrite(xml)).await?; + // Cycle detected when computing type of ... + // For more information about this error, try `rustc --explain E0391`. + // https://github.com/rust-lang/rust/issues/78649 + #[inline(always)] + fn recurse<'a>(comp: &'a CompFilter, xml: &'a mut Writer<impl IWrite>) -> futures::future::BoxFuture<'a, Result<(), QError>> { + Box::pin(comp.qwrite(xml)) + } + recurse(comp_item, xml).await?; } Ok(()) } diff --git a/aero-dav/src/error.rs b/aero-dav/src/error.rs index f1b5cba..570f779 100644 --- a/aero-dav/src/error.rs +++ b/aero-dav/src/error.rs @@ -15,6 +15,25 @@ pub enum ParsingError { Int(std::num::ParseIntError), Eof } +impl std::fmt::Display for ParsingError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Recoverable => write!(f, "Recoverable"), + Self::MissingChild => write!(f, "Missing child"), + Self::MissingAttribute => write!(f, "Missing attribute"), + Self::NamespacePrefixAlreadyUsed => write!(f, "Namespace prefix already used"), + Self::WrongToken => write!(f, "Wrong token"), + Self::TagNotFound => write!(f, "Tag not found"), + Self::InvalidValue => write!(f, "Invalid value"), + Self::Utf8Error(_) => write!(f, "Utf8 Error"), + Self::QuickXml(_) => write!(f, "Quick XML error"), + Self::Chrono(_) => write!(f, "Chrono error"), + Self::Int(_) => write!(f, "Number parsing error"), + Self::Eof => write!(f, "Found EOF while expecting data"), + } + } +} +impl std::error::Error for ParsingError {} impl From<AttrError> for ParsingError { fn from(value: AttrError) -> Self { Self::QuickXml(value.into()) diff --git a/aero-dav/src/realization.rs b/aero-dav/src/realization.rs index 5781637..a7bbb16 100644 --- a/aero-dav/src/realization.rs +++ b/aero-dav/src/realization.rs @@ -11,8 +11,8 @@ impl xml::QRead<Disabled> for Disabled { } } impl xml::QWrite for Disabled { - async fn qwrite(&self, _xml: &mut xml::Writer<impl xml::IWrite>) -> Result<(), quick_xml::Error> { - unreachable!(); + fn qwrite(&self, _xml: &mut xml::Writer<impl xml::IWrite>) -> impl futures::Future<Output = Result<(), quick_xml::Error>> + Send { + async { unreachable!(); } } } diff --git a/aero-dav/src/xml.rs b/aero-dav/src/xml.rs index 1f8a6b1..e078c6f 100644 --- a/aero-dav/src/xml.rs +++ b/aero-dav/src/xml.rs @@ -12,19 +12,19 @@ pub const CAL_URN: &[u8] = b"urn:ietf:params:xml:ns:caldav"; pub const CARD_URN: &[u8] = b"urn:ietf:params:xml:ns:carddav"; // Async traits -pub trait IWrite = AsyncWrite + Unpin; +pub trait IWrite = AsyncWrite + Unpin + Send; pub trait IRead = AsyncBufRead + Unpin; // Serialization/Deserialization traits pub trait QWrite { - fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> impl Future<Output = Result<(), quick_xml::Error>>; + fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> impl Future<Output = Result<(), quick_xml::Error>> + Send; } pub trait QRead<T> { fn qread(xml: &mut Reader<impl IRead>) -> impl Future<Output = Result<T, ParsingError>>; } // The representation of an XML node in Rust -pub trait Node<T> = QRead<T> + QWrite + std::fmt::Debug + PartialEq; +pub trait Node<T> = QRead<T> + QWrite + std::fmt::Debug + PartialEq + Sync; // --------------- |