You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/04/29 16:45:54 UTC
[incubator-opendal] 01/03: Format code
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch add-docs-for-core
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit d52a0aff66a1c95f7c0d3511391e54a76f351342
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sat Apr 29 19:12:56 2023 +0800
Format code
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
Cargo.toml | 1 +
bindings/java/Cargo.toml | 3 +--
bindings/java/src/lib.rs | 17 +++++++++------
bindings/ruby/Cargo.toml | 2 +-
core/src/raw/http_util/multipart.rs | 26 +++++++++++++++--------
core/src/services/gcs/core.rs | 1 -
core/src/services/mod.rs | 1 -
core/src/services/onedrive/backend.rs | 40 +++++++++++++++++++++++------------
core/src/services/onedrive/builder.rs | 10 ++++-----
core/src/services/supabase/backend.rs | 2 +-
core/src/services/supabase/error.rs | 5 ++++-
core/src/types/operator/operator.rs | 2 +-
core/tests/behavior/write.rs | 5 +++--
rustfmt.toml | 7 +++---
14 files changed, 75 insertions(+), 47 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 986d3cbe..696a5bbc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,6 +19,7 @@
debug = true
[workspace]
+default-members = ["core"]
members = [
"core",
diff --git a/bindings/java/Cargo.toml b/bindings/java/Cargo.toml
index 06b1fcc6..92612ca5 100644
--- a/bindings/java/Cargo.toml
+++ b/bindings/java/Cargo.toml
@@ -35,8 +35,7 @@ doc = false
jni = "0.21.1"
opendal.workspace = true
-tokio = { version = "1", features = ["full"] }
once_cell = "1.17.1"
+tokio = { version = "1", features = ["full"] }
num_cpus = "1.15.0"
-
diff --git a/bindings/java/src/lib.rs b/bindings/java/src/lib.rs
index fc8167ba..1d41d7c8 100644
--- a/bindings/java/src/lib.rs
+++ b/bindings/java/src/lib.rs
@@ -21,19 +21,24 @@ use std::ffi::c_void;
use std::str::FromStr;
use std::sync::Arc;
+use jni::objects::JClass;
use jni::objects::JMap;
use jni::objects::JObject;
use jni::objects::JString;
-use jni::objects::{JClass, JThrowable, JValue};
-use jni::sys::{jboolean, jint};
-use jni::sys::{jlong, JNI_VERSION_1_8};
-use jni::{JNIEnv, JavaVM};
+use jni::objects::JThrowable;
+use jni::objects::JValue;
+use jni::sys::jboolean;
+use jni::sys::jint;
+use jni::sys::jlong;
+use jni::sys::JNI_VERSION_1_8;
+use jni::JNIEnv;
+use jni::JavaVM;
use once_cell::sync::OnceCell;
-use tokio::runtime::{Builder, Runtime};
-
use opendal::BlockingOperator;
use opendal::Operator;
use opendal::Scheme;
+use tokio::runtime::Builder;
+use tokio::runtime::Runtime;
static mut RUNTIME: OnceCell<Runtime> = OnceCell::new();
diff --git a/bindings/ruby/Cargo.toml b/bindings/ruby/Cargo.toml
index c070193d..57500ea2 100644
--- a/bindings/ruby/Cargo.toml
+++ b/bindings/ruby/Cargo.toml
@@ -34,8 +34,8 @@ name = "opendal_ruby"
[dependencies]
magnus = { version = "0.5", features = ["bytes-crate"] }
-rb-sys = { version = "0.9.72", default-features = false }
opendal.workspace = true
+rb-sys = { version = "0.9.72", default-features = false }
[build-dependencies]
rb-sys-env = "0.1.2"
diff --git a/core/src/raw/http_util/multipart.rs b/core/src/raw/http_util/multipart.rs
index 1bff5df2..6be885bb 100644
--- a/core/src/raw/http_util/multipart.rs
+++ b/core/src/raw/http_util/multipart.rs
@@ -17,14 +17,22 @@
use std::str::FromStr;
+use bytes::Bytes;
+use bytes::BytesMut;
+use http::header::CONTENT_DISPOSITION;
+use http::header::CONTENT_LENGTH;
+use http::header::CONTENT_TYPE;
+use http::HeaderMap;
+use http::HeaderName;
+use http::HeaderValue;
+use http::Method;
+use http::Request;
+use http::Uri;
+use http::Version;
+
+use super::new_request_build_error;
+use super::AsyncBody;
use crate::*;
-use bytes::{Bytes, BytesMut};
-use http::{
- header::{CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_TYPE},
- HeaderMap, HeaderName, HeaderValue, Method, Request, Uri, Version,
-};
-
-use super::{new_request_build_error, AsyncBody};
/// Multipart is a builder for multipart/form-data.
#[derive(Debug)]
@@ -312,11 +320,11 @@ impl Part for MixedPart {
#[cfg(test)]
mod tests {
- use super::*;
-
use http::header::CONTENT_TYPE;
use pretty_assertions::assert_eq;
+ use super::*;
+
#[test]
fn test_multipart_formdata_basic() {
let multipart = Multipart::new()
diff --git a/core/src/services/gcs/core.rs b/core/src/services/gcs/core.rs
index 965d58ba..b4b4278c 100644
--- a/core/src/services/gcs/core.rs
+++ b/core/src/services/gcs/core.rs
@@ -24,7 +24,6 @@ use backon::ExponentialBuilder;
use backon::Retryable;
use bytes::Bytes;
use bytes::BytesMut;
-
use http::header::CONTENT_LENGTH;
use http::header::CONTENT_RANGE;
use http::header::CONTENT_TYPE;
diff --git a/core/src/services/mod.rs b/core/src/services/mod.rs
index a74de606..02621986 100644
--- a/core/src/services/mod.rs
+++ b/core/src/services/mod.rs
@@ -141,6 +141,5 @@ mod webhdfs;
mod onedrive;
#[cfg(feature = "services-onedrive")]
pub use onedrive::Onedrive;
-
#[cfg(feature = "services-webhdfs")]
pub use webhdfs::Webhdfs;
diff --git a/core/src/services/onedrive/backend.rs b/core/src/services/onedrive/backend.rs
index ce15965e..6e76dccb 100644
--- a/core/src/services/onedrive/backend.rs
+++ b/core/src/services/onedrive/backend.rs
@@ -15,22 +15,34 @@
// specific language governing permissions and limitations
// under the License.
-use async_trait::async_trait;
-use http::{header, Request, Response, StatusCode};
use std::fmt::Debug;
-use crate::{
- ops::{OpRead, OpWrite},
- raw::{
- build_rooted_abs_path, new_request_build_error, parse_into_metadata, parse_location,
- percent_encode_path, Accessor, AccessorInfo, AsyncBody, HttpClient, IncomingAsyncBody,
- RpRead, RpWrite,
- },
- types::Result,
- Capability, Error, ErrorKind,
-};
-
-use super::{error::parse_error, writer::OneDriveWriter};
+use async_trait::async_trait;
+use http::header;
+use http::Request;
+use http::Response;
+use http::StatusCode;
+
+use super::error::parse_error;
+use super::writer::OneDriveWriter;
+use crate::ops::OpRead;
+use crate::ops::OpWrite;
+use crate::raw::build_rooted_abs_path;
+use crate::raw::new_request_build_error;
+use crate::raw::parse_into_metadata;
+use crate::raw::parse_location;
+use crate::raw::percent_encode_path;
+use crate::raw::Accessor;
+use crate::raw::AccessorInfo;
+use crate::raw::AsyncBody;
+use crate::raw::HttpClient;
+use crate::raw::IncomingAsyncBody;
+use crate::raw::RpRead;
+use crate::raw::RpWrite;
+use crate::types::Result;
+use crate::Capability;
+use crate::Error;
+use crate::ErrorKind;
#[derive(Clone)]
pub struct OnedriveBackend {
diff --git a/core/src/services/onedrive/builder.rs b/core/src/services/onedrive/builder.rs
index b1d020aa..4dc3da91 100644
--- a/core/src/services/onedrive/builder.rs
+++ b/core/src/services/onedrive/builder.rs
@@ -16,12 +16,14 @@
// under the License.
use std::collections::HashMap;
-use std::fmt::{Debug, Formatter};
+use std::fmt::Debug;
+use std::fmt::Formatter;
use log::debug;
use super::backend::OnedriveBackend;
-use crate::raw::{normalize_root, HttpClient};
+use crate::raw::normalize_root;
+use crate::raw::HttpClient;
use crate::Scheme;
use crate::*;
@@ -66,9 +68,7 @@ use crate::*;
/// // create backend builder
/// let mut builder = Onedrive::default();
///
-/// builder
-/// .access_token("xxx")
-/// .root("/path/to/root");
+/// builder.access_token("xxx").root("/path/to/root");
///
/// let op: Operator = Operator::new(builder)?.finish();
/// Ok(())
diff --git a/core/src/services/supabase/backend.rs b/core/src/services/supabase/backend.rs
index ae252d08..2b92d2cf 100644
--- a/core/src/services/supabase/backend.rs
+++ b/core/src/services/supabase/backend.rs
@@ -71,7 +71,7 @@ use crate::*;
/// builder.key("some_anon_key");
///
/// let op: Operator = Operator::new(builder)?.finish();
-///
+///
/// Ok(())
/// }
/// ```
diff --git a/core/src/services/supabase/error.rs b/core/src/services/supabase/error.rs
index 15017871..54f6c61d 100644
--- a/core/src/services/supabase/error.rs
+++ b/core/src/services/supabase/error.rs
@@ -20,7 +20,10 @@ use http::StatusCode;
use serde::Deserialize;
use serde_json::from_slice;
-use crate::{raw::*, Error, ErrorKind, Result};
+use crate::raw::*;
+use crate::Error;
+use crate::ErrorKind;
+use crate::Result;
#[derive(Default, Debug, Deserialize)]
#[serde(default, rename_all = "camelCase")]
diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs
index 8fdd9bf7..ab0a15f7 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -1103,10 +1103,10 @@ impl Operator {
/// # use anyhow::Result;
/// # use futures::io;
/// use futures::TryStreamExt;
+ /// use opendal::ops::OpList;
/// use opendal::EntryMode;
/// use opendal::Metakey;
/// use opendal::Operator;
- /// use opendal::ops::OpList;
/// # #[tokio::main]
/// # async fn test(op: Operator) -> Result<()> {
/// let option = OpList::new().with_limit(10).with_start_after("start");
diff --git a/core/tests/behavior/write.rs b/core/tests/behavior/write.rs
index f98d8642..38f9a3f9 100644
--- a/core/tests/behavior/write.rs
+++ b/core/tests/behavior/write.rs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+use std::str::FromStr;
+use std::time::Duration;
+
use anyhow::Result;
use futures::AsyncReadExt;
use futures::AsyncSeekExt;
@@ -31,8 +34,6 @@ use opendal::Operator;
use reqwest::Url;
use sha2::Digest;
use sha2::Sha256;
-use std::str::FromStr;
-use std::time::Duration;
use super::utils::*;
diff --git a/rustfmt.toml b/rustfmt.toml
index ec3c4bc3..f4c3b57d 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -17,9 +17,10 @@
edition = "2021"
reorder_imports = true
+
# format_code_in_doc_comments = true
-# imports_granularity = "Item"
# group_imports = "StdExternalCrate"
-# where_single_line = true
-# trailing_comma = "Vertical"
+# imports_granularity = "Item"
# overflow_delimited_expr = true
+# trailing_comma = "Vertical"
+# where_single_line = true