This commit is contained in:
Robin Appelman 2026-03-26 23:44:23 +01:00
commit fb383652c8
22 changed files with 3161 additions and 3071 deletions

753
types/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,14 +1,14 @@
[package]
name = "ugc-scraper-types"
version = "0.2.0"
edition = "2021"
rust-version = "1.71.1"
version = "0.3.0"
edition = "2024"
rust-version = "1.88.0"
description = "Scraper for ugcleague.com - data types"
license = "MIT OR Apache-2.0"
homepage = "https://codeberg.org/icewind/ugc-scaper"
[dependencies]
steamid-ng = "1.0.0"
steamid-ng = "3.0.0"
serde = { version = "1.0.215", features = ["derive"], optional = true }
time = { version = "0.3.36", features = ["parsing", "macros"] }
thiserror = "2.0.12"

View file

@ -1,7 +1,7 @@
use serde::de::Error;
use std::fmt::Display;
use std::str::FromStr;
pub use steamid_ng::SteamID;
pub use steamid_ng::{SteamID, SteamIDParseError};
use thiserror::Error;
use time::error::Parse;
use time::format_description::FormatItem;
@ -680,8 +680,13 @@ pub struct Week<'a> {
}
impl MapHistory {
pub fn weeks(&self, current_season_year: u16) -> impl Iterator<Item = Result<Week, Parse>> {
const CURRENT_DATE_FORMAT: &[FormatItem<'static>] = format_description!("[weekday case_sensitive:false repr:short], [month repr:short] [day padding:none] [year]");
pub fn weeks<'a>(
&'a self,
current_season_year: u16,
) -> impl Iterator<Item = Result<Week<'a>, Parse>> {
const CURRENT_DATE_FORMAT: &[FormatItem<'static>] = format_description!(
"[weekday case_sensitive:false repr:short], [month repr:short] [day padding:none] [year]"
);
let current_season = self.current.maps.iter().map(move |map| {
Ok(Week {
@ -743,7 +748,9 @@ pub struct PreviousSeasonMap {
#[cfg(feature = "serde")]
pub mod serde_steam_id_as_string {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::Cow;
use std::str::FromStr;
use steamid_ng::SteamID;
pub fn serialize<S: Serializer>(steam_id: &SteamID, serializer: S) -> Result<S::Ok, S::Error> {
@ -756,6 +763,7 @@ pub mod serde_steam_id_as_string {
where
D: Deserializer<'de>,
{
SteamID::deserialize(deserializer)
let s = <Cow<'de, str>>::deserialize(deserializer)?;
SteamID::from_str(&s).map_err(D::Error::custom)
}
}