style: format Cub library modules
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -41,10 +41,53 @@ pub struct AurPackage {
|
||||
#[serde(rename = "LastModified")]
|
||||
pub last_modified: i64,
|
||||
#[serde(rename = "OutOfDate")]
|
||||
#[serde(default)]
|
||||
#[serde(default, deserialize_with = "deserialize_out_of_date")]
|
||||
pub out_of_date: Option<bool>,
|
||||
}
|
||||
|
||||
fn deserialize_out_of_date<'de, D>(deserializer: D) -> Result<Option<bool>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
use serde::de;
|
||||
|
||||
struct OutOfDateVisitor;
|
||||
|
||||
impl<'de> de::Visitor<'de> for OutOfDateVisitor {
|
||||
type Value = Option<bool>;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
formatter.write_str("null, boolean, or integer")
|
||||
}
|
||||
|
||||
fn visit_none(self) -> Result<Self::Value, de::Error> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn visit_unit(self) -> Result<Self::Value, de::Error> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn visit_bool(self, v: bool) -> Result<Self::Value, de::Error> {
|
||||
Ok(Some(v))
|
||||
}
|
||||
|
||||
fn visit_i64(self, v: i64) -> Result<Self::Value, de::Error> {
|
||||
Ok(Some(v != 0))
|
||||
}
|
||||
|
||||
fn visit_u64(self, v: u64) -> Result<Self::Value, de::Error> {
|
||||
Ok(Some(v != 0))
|
||||
}
|
||||
|
||||
fn visit_f64(self, v: f64) -> Result<Self::Value, de::Error> {
|
||||
Ok(Some(v != 0.0))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_any(OutOfDateVisitor)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct AurRpcResponse {
|
||||
version: i64,
|
||||
@@ -200,7 +243,10 @@ fn parse_rpc_response(body: &str, empty_message: &str) -> Result<Vec<AurPackage>
|
||||
.map_err(|err| aur_error(format!("failed to parse JSON response: {err}")))?;
|
||||
|
||||
if rpc.version != 5 {
|
||||
return Err(aur_error(format!("unexpected RPC version: {}", rpc.version)));
|
||||
return Err(aur_error(format!(
|
||||
"unexpected RPC version: {}",
|
||||
rpc.version
|
||||
)));
|
||||
}
|
||||
|
||||
if rpc.response_type == "error" {
|
||||
@@ -208,7 +254,10 @@ fn parse_rpc_response(body: &str, empty_message: &str) -> Result<Vec<AurPackage>
|
||||
return Err(aur_error(message));
|
||||
}
|
||||
|
||||
if rpc.response_type != "search" && rpc.response_type != "multiinfo" && rpc.response_type != "info" {
|
||||
if rpc.response_type != "search"
|
||||
&& rpc.response_type != "multiinfo"
|
||||
&& rpc.response_type != "info"
|
||||
{
|
||||
return Err(aur_error(format!(
|
||||
"unexpected RPC response type: {}",
|
||||
rpc.response_type
|
||||
|
||||
@@ -8,8 +8,8 @@ pub mod error;
|
||||
pub mod package;
|
||||
pub mod pkgbuild;
|
||||
pub mod rbpkgbuild;
|
||||
pub mod recipe;
|
||||
pub mod rbsrcinfo;
|
||||
pub mod recipe;
|
||||
pub mod sandbox;
|
||||
pub mod storage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user