Skip to content

Commit

Permalink
feat(all): upgrade/update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
martsokha committed Jun 18, 2024
1 parent 4474a31 commit 22d2f43
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 96 deletions.
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ authors = ["Oleh Martsokha <[email protected]>"]
license = "MIT"

[workspace.dependencies]
tokio = { version = "1.37.0", default-features = false }
futures-io = { version = "0.3.30", default-features = false }
futures-util = { version = "0.3.30", default-features = false }
futures-test = { version = "0.3.30", default-features = false }
tokio = { version = "1.38", default-features = false }
futures-io = { version = "0.3", default-features = false }
futures-util = { version = "0.3", default-features = false }
futures-test = { version = "0.3", default-features = false }

url = { version = "2.5.0" }
async-trait = { version = "0.1.80" }
thiserror = { version = "1.0.60" }
url = { version = "2.5" }
async-trait = { version = "0.1" }
thiserror = { version = "1.0" }

serde = { version = "1.0.201" }
serde_json = { version = "1.0.117" }
time = { version = "0.3.36", default-features = false }
serde = { version = "1.0" }
serde_json = { version = "1.0" }
time = { version = "0.3", default-features = false }
8 changes: 4 additions & 4 deletions robotxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ serde = ["dep:serde", "url/serde", "serde/derive", "serde/rc"]
[dependencies]
url = { workspace = true }
thiserror = { workspace = true }
percent-encoding = { version = "2.3.1" }
percent-encoding = { version = "2.3" }

nom = { version = "7.1.3", optional = true }
bstr = { version = "1.9.1", optional = true }
regex = { version = "1.10.4", optional = true }
nom = { version = "7.1", optional = true }
bstr = { version = "1.9", optional = true }
regex = { version = "1.10", optional = true }
serde = { workspace = true, optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion robotxt/build/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl GroupBuilder {
/// u.crawl_delay(5)
/// });
/// ```
pub fn crawl_delay(mut self, delay: u16) -> Self {
pub const fn crawl_delay(mut self, delay: u16) -> Self {
self.delay = Some(delay);
self
}
Expand Down
2 changes: 1 addition & 1 deletion robotxt/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl fmt::Display for RobotsBuilder {
let header = self.header.as_ref().map(|h| format_comment(h));
let footer = self.footer.as_ref().map(|f| format_comment(f));

let groups = self.groups.iter().map(|u| u.to_string());
let groups = self.groups.iter().map(ToString::to_string);
let groups = groups.collect::<Vec<_>>().join("\n\n");

let result = [header, Some(groups), footer];
Expand Down
12 changes: 6 additions & 6 deletions robotxt/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub use url;
#[cfg(feature = "builder")]
pub use build::{GroupBuilder, RobotsBuilder};
#[cfg(feature = "parser")]
pub use parse::{AccessResult, ALL_UAS, Robots};
pub use paths::{BYTE_LIMIT, create_url};
pub use parse::{AccessResult, Robots, ALL_UAS};
pub use paths::{create_url, BYTE_LIMIT};

/// Unrecoverable failure during `robots.txt` building or parsing.
///
Expand Down Expand Up @@ -53,10 +53,10 @@ mod parse;

#[doc(hidden)]
pub mod prelude {
pub use super::{Error, Result};
#[cfg(feature = "builder")]
pub use super::build::{GroupBuilder, RobotsBuilder};
pub use super::build::{GroupBuilder, RobotsBuilder};
#[cfg(feature = "parser")]
pub use super::parse::{AccessResult, ALL_UAS, Robots};
pub use super::paths::{BYTE_LIMIT, create_url};
pub use super::parse::{AccessResult, Robots, ALL_UAS};
pub use super::paths::{create_url, BYTE_LIMIT};
pub use super::{Error, Result};
}
8 changes: 4 additions & 4 deletions sitemapo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ extension = ["dep:isolang"]
[dependencies]
url = { workspace = true }
thiserror = { workspace = true }
countio = { version = "0.2.17" }
countio = { version = "0.2" }

quick-xml = { version = "0.31.0" }
bytes = { version = "1.6.0", features = [] }
quick-xml = { version = "0.31" }
bytes = { version = "1.6", features = [] }
time = { workspace = true, features = ["parsing", "formatting"] }

tokio = { workspace = true, optional = true }
async-trait = { workspace = true, optional = true }
isolang = { version = "2.4.0", optional = true, features = [] }
isolang = { version = "2.4", optional = true, features = [] }

[dev-dependencies]
time = { workspace = true, features = ["macros"] }
Expand Down
7 changes: 5 additions & 2 deletions sitemapo/build/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use quick_xml::{events, Writer};
use time::format_description::well_known::Iso8601;

use crate::build::{Builder, InnerBuilder, CONFIG};
use crate::record::*;
use crate::record::{
Entry, BYTE_LIMIT, CHANGE_FREQUENCY, LAST_MODIFIED, LOCATION, PRIORITY, RECORD_LIMIT, URL,
URL_SET,
};
use crate::{Error, Result};

/// Sitemap builder for the versatile XML file with an optional support of extensions.
Expand Down Expand Up @@ -51,7 +54,7 @@ impl<W> EntryBuilder<W> {
}

/// Creates a new instance with the given inner parser.
pub(crate) fn from_inner(inner: InnerBuilder<W, Entry>) -> Self {
pub(crate) const fn from_inner(inner: InnerBuilder<W, Entry>) -> Self {
Self { inner }
}

Expand Down
6 changes: 4 additions & 2 deletions sitemapo/build/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use quick_xml::{events, Writer};
use time::format_description::well_known::Iso8601;

use crate::build::{Builder, InnerBuilder, CONFIG};
use crate::record::*;
use crate::record::{
Index, BYTE_LIMIT, LAST_MODIFIED, LOCATION, RECORD_LIMIT, SITEMAP, SITEMAP_INDEX,
};
use crate::{Error, Result};

/// Sitemap index parser for the versatile XML file.
Expand Down Expand Up @@ -51,7 +53,7 @@ impl<W> IndexBuilder<W> {
}

/// Creates a new instance with the given inner parser.
pub(crate) fn from_inner(inner: InnerBuilder<W, Index>) -> Self {
pub(crate) const fn from_inner(inner: InnerBuilder<W, Index>) -> Self {
Self { inner }
}

Expand Down
2 changes: 1 addition & 1 deletion sitemapo/build/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use time::format_description::well_known::iso8601;

use crate::Error;

pub(crate) const CONFIG: iso8601::EncodedConfig = iso8601::Config::DEFAULT
pub const CONFIG: iso8601::EncodedConfig = iso8601::Config::DEFAULT
.set_time_precision(iso8601::TimePrecision::Second {
decimal_digits: NonZeroU8::new(2),
})
Expand Down
3 changes: 2 additions & 1 deletion sitemapo/build/plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use countio::Counter;
use url::Url;

use crate::build::Builder;
use crate::record::*;
use crate::record::{BYTE_LIMIT, RECORD_LIMIT};
use crate::{Error, Result};

/// Sitemap builder for the simple TXT file that contains one URL per line.
Expand Down Expand Up @@ -144,6 +144,7 @@ mod tokio {
#[cfg(test)]
mod test {
use std::io::BufWriter;

use url::Url;

use crate::build::{Builder, PlainBuilder};
Expand Down
2 changes: 1 addition & 1 deletion sitemapo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub mod record;

#[doc(hidden)]
pub mod prelude {
pub use super::{Error, Result};
pub use super::build::*;
pub use super::parse::*;
pub use super::record::*;
pub use super::{Error, Result};
}
14 changes: 9 additions & 5 deletions sitemapo/parse/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use countio::Counter;
use quick_xml::{events, Reader};
use url::Url;

use crate::{parse::*, record::*, Error};
use crate::{
parse::{try_if_readable, EntryParser, IndexParser, InnerParser, Parser, PlainParser},
record::{Entry, SITEMAP_INDEX, URL_SET},
Error,
};

/// Sitemap type resolver.
// TODO: Check for the plain txt sitemaps.
Expand Down Expand Up @@ -147,9 +151,9 @@ impl<R> AutoParser<R> {
/// Returns minimal (no resolved indexes) total sitemaps amount.
pub fn len(&self) -> usize {
self.sitemaps.len()
+ self.plain.is_some() as usize
+ self.index.is_some() as usize
+ self.entry.is_some() as usize
+ usize::from(self.plain.is_some())
+ usize::from(self.index.is_some())
+ usize::from(self.entry.is_some())
}
}

Expand Down Expand Up @@ -199,7 +203,7 @@ where
if let Some(sitemap) = self.sitemaps.pop() {
let reader = (fetcher)(sitemap)?;
if let Ok(sitemap) = Scanner::from_sync(reader) {
self.replace_parser(sitemap)
self.replace_parser(sitemap);
}
}

Expand Down
12 changes: 6 additions & 6 deletions sitemapo/parse/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{Error, Result};

/// [`Entry`] builder.
#[derive(Debug, Clone, Default)]
pub(crate) struct EntryFactory {
pub struct EntryFactory {
location: Option<Url>,
modified: Option<OffsetDateTime>,
priority: Option<Priority>,
Expand Down Expand Up @@ -78,7 +78,7 @@ impl<R> EntryParser<R> {
}

/// Creates a new instance with the given inner parser.
pub(crate) fn from_inner(inner: InnerParser<R, EntryFactory>) -> Self {
pub(crate) const fn from_inner(inner: InnerParser<R, EntryFactory>) -> Self {
Self { inner }
}

Expand Down Expand Up @@ -114,17 +114,17 @@ impl<R> EntryParser<R> {
}
}

pub(crate) fn write_event(&mut self, event: events::Event) -> Result<Output<Entry>> {
pub(crate) fn write_event(&mut self, event: events::Event) -> Output<Entry> {
let tag = URL.as_bytes();
let builder = self.inner.write_event(event, tag, Self::apply_inner);

if let Ok(Output::Some(r)) = builder {
if let Some(record) = r.build() {
return Ok(Output::Some(record));
return Output::Some(record);
}
}

Ok(Output::None)
Output::None
}
}

Expand All @@ -149,7 +149,7 @@ impl<R: std::io::BufRead> Parser<R, Entry> for EntryParser<R> {
loop {
self.inner.try_if_readable()?;
let event = self.inner.reader.read_event_into(&mut buf)?;
match self.write_event(event)? {
match self.write_event(event) {
Output::Some(record) => return Ok(Some(record)),
Output::None => {}
Output::End => return Ok(None),
Expand Down
12 changes: 6 additions & 6 deletions sitemapo/parse/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{Error, Result};

/// [`Index`] builder.
#[derive(Debug, Clone, Default)]
pub(crate) struct IndexFactory {
pub struct IndexFactory {
pub(crate) location: Option<Url>,
pub(crate) modified: Option<OffsetDateTime>,
}
Expand Down Expand Up @@ -53,7 +53,7 @@ impl<R> IndexParser<R> {
}

/// Creates a new instance with the given inner parser.
pub(crate) fn from_inner(inner: InnerParser<R, IndexFactory>) -> Self {
pub(crate) const fn from_inner(inner: InnerParser<R, IndexFactory>) -> Self {
Self { inner }
}

Expand Down Expand Up @@ -85,17 +85,17 @@ impl<R> IndexParser<R> {
}
}

pub(crate) fn write_event(&mut self, event: events::Event) -> Result<Output<Index>> {
pub(crate) fn write_event(&mut self, event: events::Event) -> Output<Index> {
let tag = SITEMAP.as_bytes();
let builder = self.inner.write_event(event, tag, Self::apply_inner);

if let Ok(Output::Some(r)) = builder {
if let Some(record) = r.build() {
return Ok(Output::Some(record));
return Output::Some(record);
}
}

Ok(Output::None)
Output::None
}
}

Expand All @@ -120,7 +120,7 @@ impl<R: std::io::BufRead> Parser<R, Index> for IndexParser<R> {
loop {
self.inner.try_if_readable()?;
let event = self.inner.reader.read_event_into(&mut buf)?;
match self.write_event(event)? {
match self.write_event(event) {
Output::Some(record) => return Ok(Some(record)),
Output::None => {}
Output::End => return Ok(None),
Expand Down
8 changes: 4 additions & 4 deletions sitemapo/parse/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use quick_xml::{events::Event, Reader};
use crate::parse::try_if_readable;
use crate::Result;

pub(crate) enum Output<T> {
pub enum Output<T> {
/// Next record.
Some(T),
/// The event didn't result into the new record.
Expand All @@ -16,11 +16,11 @@ pub(crate) enum Output<T> {

impl<T> From<Option<T>> for Output<T> {
fn from(value: Option<T>) -> Self {
value.map(Output::Some).unwrap_or(Output::End)
value.map_or(Self::End, Self::Some)
}
}

pub(crate) struct InnerParser<R, D> {
pub struct InnerParser<R, D> {
pub(crate) record: Option<D>,
pub(crate) reader: Reader<Counter<R>>,
pub(crate) records: usize,
Expand Down Expand Up @@ -113,6 +113,6 @@ impl<R, D> std::fmt::Debug for InnerParser<R, D> {
f.debug_struct("InnerParser")
.field("bytes", &self.reader.get_ref().reader_bytes())
.field("records", &self.records)
.finish()
.finish_non_exhaustive()
}
}
14 changes: 7 additions & 7 deletions sitemapo/parse/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
mod auto;
mod entry;
mod index;
mod inner;
mod plain;

pub use auto::*;
pub use entry::*;
pub use index::*;
pub(crate) use inner::*;
pub use plain::*;

mod auto;
mod entry;
mod index;
mod inner;
mod plain;

/// Core trait for the parser implementation.
pub trait Parser<R: std::io::Read, D>: Sized {
type Error: std::error::Error;
Expand Down Expand Up @@ -41,7 +41,7 @@ pub trait AsyncParser<R: tokio::io::AsyncRead, D>: Sized {
async fn close(self) -> Result<R, Self::Error>;
}

pub(crate) fn try_if_readable(records: usize, bytes: usize) -> crate::Result<()> {
pub(crate) const fn try_if_readable(records: usize, bytes: usize) -> crate::Result<()> {
use crate::record::{BYTE_LIMIT, RECORD_LIMIT};

if records + 1 > RECORD_LIMIT {
Expand Down
Loading

0 comments on commit 22d2f43

Please sign in to comment.