Skip to content

Commit

Permalink
chore: Make 1.79 clippy happy (#4731)
Browse files Browse the repository at this point in the history
* chore: Make 1.79 clippy happy

Signed-off-by: Xuanwo <[email protected]>

* Fix clippy

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jun 14, 2024
1 parent 501a87f commit c4d602a
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 106 deletions.
2 changes: 2 additions & 0 deletions bin/ofs/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ static RUNTIME: OnceLock<Runtime> = OnceLock::new();

pub struct OfsTestContext {
pub mount_point: TempDir,
// This is a false positive, the field is used in the test.
#[allow(dead_code)]
pub capability: Capability,
mount_handle: MountHandle,
}
Expand Down
11 changes: 0 additions & 11 deletions core/src/raw/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,3 @@

/// VERSION is the compiled version of OpenDAL.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_version() {
println!("opendal version: {VERSION}");
assert!(!VERSION.is_empty())
}
}
24 changes: 2 additions & 22 deletions core/src/services/aliyun_drive/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl AliyunDriveCore {
let mut tokener = self.signer.lock().await;
if tokener.expire_at < Utc::now().timestamp() || tokener.access_token.is_none() {
let res = self.get_access_token(&tokener.refresh_token).await?;
let output: RefresTokenResponse =
let output: RefreshTokenResponse =
serde_json::from_reader(res.reader()).map_err(new_json_deserialize_error)?;
tokener.access_token = Some(output.access_token);
tokener.expire_at = output.expires_in + Utc::now().timestamp();
Expand Down Expand Up @@ -412,17 +412,14 @@ pub struct RapidUpload {
}

#[derive(Debug, Deserialize)]
pub struct RefresTokenResponse {
pub struct RefreshTokenResponse {
pub access_token: String,
pub expires_in: i64,
pub refresh_token: String,
}

#[derive(Debug, Deserialize)]
pub struct DriveInfoResponse {
pub user_id: String,
pub name: String,
pub avatar: String,
pub default_drive_id: String,
pub resource_drive_id: Option<String>,
pub backup_drive_id: Option<String>,
Expand All @@ -444,22 +441,13 @@ pub enum CheckNameMode {

#[derive(Deserialize)]
pub struct UploadUrlResponse {
pub drive_id: String,
pub file_id: String,
pub upload_id: Option<String>,
pub part_info_list: Option<Vec<PartInfo>>,
}

#[derive(Deserialize)]
pub struct CreateResponse {
pub drive_id: String,
pub file_id: String,
pub status: Option<String>,
pub parent_file_id: String,
pub upload_id: Option<String>,
pub file_name: String,
pub available: Option<bool>,
pub exist: Option<bool>,
pub rapid_upload: Option<bool>,
pub part_info_list: Option<Vec<PartInfo>>,
}
Expand All @@ -481,32 +469,24 @@ pub struct AliyunDriveFileList {

#[derive(Deserialize)]
pub struct CopyResponse {
pub drive_id: String,
pub file_id: String,
}

#[derive(Deserialize)]
pub struct AliyunDriveFile {
pub drive_id: String,
pub file_id: String,
pub parent_file_id: String,
pub name: String,
pub size: Option<u64>,
pub file_extension: Option<String>,
pub content_hash: Option<String>,
pub content_type: Option<String>,
pub category: Option<String>,
#[serde(rename = "type")]
pub path_type: String,
pub created_at: String,
pub updated_at: String,
}

#[derive(Deserialize)]
pub struct GetDownloadUrlResponse {
pub url: String,
pub expiration: String,
pub method: String,
}

#[derive(Serialize)]
Expand Down
1 change: 0 additions & 1 deletion core/src/services/b2/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ pub struct File {
pub content_md5: Option<String>,
pub content_type: Option<String>,
pub file_name: String,
pub action: String,
}

pub(super) fn parse_file_info(file: &File) -> Metadata {
Expand Down
3 changes: 0 additions & 3 deletions core/src/services/chainsafe/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,8 @@ impl ChainsafeCore {
#[derive(Debug, Deserialize)]
pub struct Info {
pub name: String,
pub cid: String,
pub content_type: String,
pub size: u64,
pub version: i64,
pub created_at: i64,
}

#[derive(Deserialize)]
Expand Down
21 changes: 0 additions & 21 deletions core/src/services/d1/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub struct D1Response {
pub result: Vec<D1Result>,
pub success: bool,
pub errors: Vec<D1Error>,
pub messages: Vec<D1Message>,
}

impl D1Response {
Expand Down Expand Up @@ -77,21 +76,7 @@ impl D1Response {

#[derive(Deserialize, Debug)]
pub struct D1Result {
pub meta: Meta,
pub results: Vec<Map<String, Value>>,
pub success: bool,
}

#[derive(Deserialize, Debug)]
pub struct Meta {
pub served_by: String,
pub duration: f64,
pub changes: i32,
pub last_row_id: i32,
pub changed_db: bool,
pub size_after: i32,
pub rows_read: i32,
pub rows_written: i32,
}

#[derive(Clone, Deserialize, Debug, Serialize)]
Expand All @@ -100,12 +85,6 @@ pub struct D1Error {
pub code: i32,
}

#[derive(Deserialize, Debug)]
pub struct D1Message {
pub message: String,
pub code: i32,
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
4 changes: 0 additions & 4 deletions core/src/services/icloud/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,12 @@ pub struct Webservices {
#[derive(Deserialize, Default, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Drivews {
pub pcs_required: bool,
pub status: String,
pub url: Option<String>,
}

#[derive(Deserialize, Default, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Docws {
pub pcs_required: bool,
pub status: String,
pub url: Option<String>,
}

Expand Down
34 changes: 0 additions & 34 deletions core/src/services/oss/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,6 @@ pub struct CompleteMultipartUploadRequest {
pub part: Vec<MultipartUploadPart>,
}

#[derive(Default, Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct CompleteMultipartUploadResult {
pub location: String,
pub bucket: String,
pub key: String,
#[serde(rename = "ETag")]
pub etag: String,
}

#[derive(Default, Debug, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
pub struct ListObjectsOutput {
Expand Down Expand Up @@ -822,30 +812,6 @@ mod tests {
)
}

#[test]
fn test_deserialize_complete_oss_multipart_result() {
let bytes = Bytes::from(
r#"<?xml version="1.0" encoding="UTF-8"?>
<CompleteMultipartUploadResult xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com">
<EncodingType>url</EncodingType>
<Location>http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data</Location>
<Bucket>oss-example</Bucket>
<Key>multipart.data</Key>
<ETag>"B864DB6A936D376F9F8D3ED3BBE540****"</ETag>
</CompleteMultipartUploadResult>"#,
);

let result: CompleteMultipartUploadResult =
quick_xml::de::from_reader(bytes.reader()).unwrap();
assert_eq!("\"B864DB6A936D376F9F8D3ED3BBE540****\"", result.etag);
assert_eq!(
"http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data",
result.location
);
assert_eq!("oss-example", result.bucket);
assert_eq!("multipart.data", result.key);
}

#[test]
fn test_parse_list_output() {
let bs = bytes::Bytes::from(
Expand Down
4 changes: 0 additions & 4 deletions core/src/services/pcloud/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,9 @@ pub struct StatResponse {

#[derive(Debug, Deserialize)]
pub struct StatMetadata {
pub name: String,
pub modified: String,
pub isfolder: bool,
pub size: Option<u64>,
pub contenttype: Option<String>,
}

#[derive(Debug, Deserialize)]
Expand All @@ -428,11 +426,9 @@ pub struct ListFolderResponse {

#[derive(Debug, Deserialize)]
pub struct ListMetadata {
pub name: String,
pub path: String,
pub modified: String,
pub isfolder: bool,
pub size: Option<u64>,
pub contenttype: Option<String>,
pub contents: Option<Vec<ListMetadata>>,
}
5 changes: 1 addition & 4 deletions core/src/services/swift/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ impl Builder for SwiftBuilder {
};
debug!("backend use container: {}", &container);

let token = match self.token.take() {
Some(token) => token,
None => String::new(),
};
let token = self.token.take().unwrap_or_default();

let client = HttpClient::new()?;

Expand Down
1 change: 0 additions & 1 deletion core/src/services/yandex_disk/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ pub struct GetUploadUrlResponse {
pub struct MetainformationResponse {
#[serde(rename = "type")]
pub ty: String,
pub name: String,
pub path: String,
pub modified: String,
pub md5: Option<String>,
Expand Down
1 change: 0 additions & 1 deletion core/tests/behavior/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use std::mem;
use std::sync::Mutex;
use std::usize;

use futures::Future;
use libtest_mimic::Failed;
Expand Down

0 comments on commit c4d602a

Please sign in to comment.