sitemapo 0.2.0

The implementation of the Sitemap.xml (or URL inclusion) protocol with the support of txt & xml formats, and video, image, news extensions.
Documentation
mod auto;
mod txt;
mod xml;

pub use auto::*;
pub use txt::*;
pub use xml::*;

/// Core trait for the sitemap parser implementation.
pub trait Parser<R: std::io::Read, D>: Sized {
    type Error: std::error::Error;

    // Creates a new `Parser` instance.
    fn new(reader: R) -> Result<Self, Self::Error>;

    /// Reads another record from the underlying reader.
    fn read(&mut self) -> Result<Option<D>, Self::Error>;

    /// Closes tags if needed and releases the reader.
    fn close(self) -> Result<R, Self::Error>;
}

/// Core trait for the async sitemap builder implementation.
#[cfg(feature = "tokio")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
#[async_trait::async_trait]
pub trait AsyncParser<R: tokio::io::AsyncRead, D>: Sized {
    type Error: std::error::Error;

    // Creates a new `AsyncParser` instance.
    async fn new(reader: R) -> Result<Self, Self::Error>;

    /// Reads another record from the underlying reader.
    async fn read(&mut self) -> Result<Option<D>, Self::Error>;

    /// Closes tags if needed and releases the reader.
    async fn close(self) -> Result<R, Self::Error>;
}