Struct Bucket

Source
#[non_exhaustive]
pub struct Bucket<PointerSel: PointerFamily = ArcPointer> { /* private fields */ }
Expand description

内置的存放单个 bucket 的类型

Implementations§

Source§

impl<T: PointerFamily> Bucket<T>

Source

pub fn new( base: BucketBase, creation_date: DateTime<Utc>, storage_class: StorageClass, client: T::PointerType, ) -> Self

初始化 Bucket

Source

pub fn creation_date(&self) -> &DateTime<Utc>

获取 bucket 创建时间

Source

pub fn storage_class(&self) -> &StorageClass

获取 storage_class

Source

pub fn base(&self) -> &BucketBase

读取 bucket 基本信息

Source§

impl Bucket

Source

pub async fn get_object_list<Q: IntoIterator<Item = (QueryKey, QueryValue)>>( &self, query: Q, ) -> Result<ObjectList, ExtractListError>

§查询 Object 列表

参数 query 有多种写法:

  • [] 查所有
  • [("max-keys".into(), "5".into())] 数组(不可变长度),最大可支持 size 为 8 的数组
  • [("max-keys".into(), "5".into()), ("prefix".into(), "babel".into())] 数组(不可变长度)
  • vec![("max-keys".into(), "5".into())] Vec(可变长度)
  • vec![("max-keys".into(), 5u8.into())] 数字类型
  • vec![("max-keys".into(), 1000u16.into())] u16 数字类型
Source

pub async fn get_object_list2( &self, query: Query, ) -> Result<ObjectList, ExtractListError>

§查询 Object 列表
Source§

impl Bucket<RcPointer>

Source

pub fn get_object_list<Q: IntoIterator<Item = (QueryKey, QueryValue)>>( &self, query: Q, ) -> Result<ObjectList<RcPointer>, ExtractListError>

查询默认 bucket 的文件列表

查询条件参数有多种方式,具体参考 get_object_list 文档

Trait Implementations§

Source§

impl AlignBuilder for Bucket

Source§

fn builder_with_header<H: IntoIterator<Item = (HeaderName, HeaderValue)>>( &self, method: Method, url: Url, resource: CanonicalizedResource, headers: H, ) -> Result<RequestBuilder, BuilderError>

根据具体的 API 接口参数,返回请求的构建器
Source§

fn builder( &self, method: Method, url: Url, resource: CanonicalizedResource, ) -> Result<RequestBuilder, BuilderError>

根据具体的 API 接口参数,返回请求的构建器(不带 headers)
Source§

impl AlignBuilder for Bucket<RcPointer>

§对齐 Client, Bucket, ObjectList 等结构体的 trait

用于他们方便的实现 File trait

Source§

fn builder_with_header<H: IntoIterator<Item = (HeaderName, HeaderValue)>>( &self, method: Method, url: Url, resource: CanonicalizedResource, headers: H, ) -> Result<RequestBuilder, BuilderError>

根据具体的 API 接口参数,返回请求的构建器
Source§

fn builder( &self, method: Method, url: Url, resource: CanonicalizedResource, ) -> Result<RequestBuilder, BuilderError>

根据具体的 API 接口参数,返回请求的构建器(不带 headers)
Source§

impl<T: PointerFamily> AsRef<BucketBase> for Bucket<T>

Source§

fn as_ref(&self) -> &BucketBase

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: PointerFamily> AsRef<BucketName> for Bucket<T>

Source§

fn as_ref(&self) -> &BucketName

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: PointerFamily> AsRef<EndPoint> for Bucket<T>

Source§

fn as_ref(&self) -> &EndPoint

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<PointerSel: Clone + PointerFamily> Clone for Bucket<PointerSel>
where PointerSel::PointerType: Clone,

Source§

fn clone(&self) -> Bucket<PointerSel>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: PointerFamily> Debug for Bucket<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PointerFamily> Default for Bucket<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GetStdWithPath<&ObjectBase<RcPointer>> for Bucket

§用于在 Bucket 上对文件进行操作

文件路径可以是 &ObjectBase 类型

Source§

fn get_std_with_path( &self, base: &ObjectBase<RcPointer>, ) -> Option<(Url, CanonicalizedResource)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl GetStdWithPath<&ObjectBase> for Bucket

§用于在 Bucket 上对文件进行操作

文件路径可以是 &ObjectBase 类型

Source§

fn get_std_with_path( &self, base: &ObjectBase<ArcPointer>, ) -> Option<(Url, CanonicalizedResource)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl GetStdWithPath<ObjectBase<RcPointer>> for Bucket

§用于在 Bucket 上对文件进行操作

文件路径可以是 ObjectBase 类型

Source§

fn get_std_with_path( &self, base: ObjectBase<RcPointer>, ) -> Option<(Url, CanonicalizedResource)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl GetStdWithPath<ObjectBase> for Bucket

§用于在 Bucket 上对文件进行操作

文件路径可以是 ObjectBase 类型

Source§

fn get_std_with_path( &self, base: ObjectBase<ArcPointer>, ) -> Option<(Url, CanonicalizedResource)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl<PointerSel: Hash + PointerFamily> Hash for Bucket<PointerSel>
where PointerSel::PointerType: Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl InitObject<Bucket<RcPointer>> for ListBuckets<RcPointer>

Source§

fn init_object(&mut self) -> Option<Bucket<RcPointer>>

初始化 object 的类型 Read more
Source§

impl InitObject<Bucket> for ListBuckets

Source§

fn init_object(&mut self) -> Option<Bucket>

初始化 object 的类型 Read more
Source§

impl<T: PointerFamily> PartialEq<BucketBase> for Bucket<T>

Source§

fn eq(&self, other: &BucketBase) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PointerFamily> PartialEq<DateTime<Utc>> for Bucket<T>

Source§

fn eq(&self, other: &DateTime<Utc>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PointerFamily> PartialEq for Bucket<T>

Source§

fn eq(&self, other: &Bucket<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PointerFamily> RefineBucket<BucketError> for Bucket<T>

Source§

fn set_name(&mut self, name: &str) -> Result<(), BucketError>

提取 bucket name
Source§

fn set_location(&mut self, location: &str) -> Result<(), BucketError>

提取 location
Source§

fn set_creation_date(&mut self, creation_date: &str) -> Result<(), BucketError>

提取 bucket 创建时间
Source§

fn set_storage_class(&mut self, storage_class: &str) -> Result<(), BucketError>

提取 storage_class
Source§

fn set_extranet_endpoint( &mut self, _extranet_endpoint: &str, ) -> Result<(), Error>

提取 extranet_endpoint
Source§

fn set_intranet_endpoint( &mut self, _intranet_endpoint: &str, ) -> Result<(), Error>

提取 intranet_endpoint
Source§

fn decode(&mut self, xml: &str) -> Result<(), InnerItemError>

解析 OSS 接口返回的 xml 数据

Auto Trait Implementations§

§

impl<PointerSel> Freeze for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: Freeze,

§

impl<PointerSel> RefUnwindSafe for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: RefUnwindSafe,

§

impl<PointerSel> Send for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: Send,

§

impl<PointerSel> Sync for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: Sync,

§

impl<PointerSel> Unpin for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: Unpin,

§

impl<PointerSel> UnwindSafe for Bucket<PointerSel>
where <PointerSel as PointerFamily>::PointerType: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<P, T> Files<P> for T
where P: Send + Sync + 'static, T: AlignBuilder + GetStdWithPath<P>,

Source§

const DEFAULT_CONTENT_TYPE: &'static str = DEFAULT_CONTENT_TYPE

默认的文件类型 Read more
Source§

fn put_file<'life0, 'async_trait, P>( &'life0 self, file_name: P, path: Path, ) -> Pin<Box<dyn Future<Output = Result<String, FileError>> + Send + 'async_trait>>
where P: 'async_trait + Into<PathBuf> + AsRef<Path> + Send + Sync, Self: Sync + 'async_trait, 'life0: 'async_trait,

上传文件到 OSS Read more
Source§

fn put_content<'life0, 'async_trait, F>( &'life0 self, content: Vec<u8>, path: Path, get_content_type: F, ) -> Pin<Box<dyn Future<Output = Result<String, FileError>> + Send + 'async_trait>>
where F: Fn(&Vec<u8>) -> Option<&'static str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

上传文件内容到 OSS Read more
Source§

fn put_content_base<'life0, 'life1, 'async_trait>( &'life0 self, content: Vec<u8>, content_type: &'life1 str, path: Path, ) -> Pin<Box<dyn Future<Output = Result<Response, FileError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

最核心的上传文件到 OSS 的方法
Source§

fn get_object<'life0, 'async_trait, Num, R>( &'life0 self, path: Path, range: R, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, FileError>> + Send + 'async_trait>>
where R: Into<ContentRange<Num>> + Send + Sync + 'async_trait, ContentRange<Num>: Into<HeaderValue>, Num: 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

获取 OSS 上文件的部分或全部内容 Read more
Source§

fn delete_object<'life0, 'async_trait>( &'life0 self, path: Path, ) -> Pin<Box<dyn Future<Output = Result<(), FileError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

删除 OSS 上的文件 Read more
Source§

impl<P, T> Files<P> for T

Source§

const DEFAULT_CONTENT_TYPE: &'static str = super::DEFAULT_CONTENT_TYPE

默认的文件类型 Read more
Source§

fn put_file<P: Into<PathBuf> + AsRef<Path>>( &self, file_name: P, path: Path, ) -> Result<String, FileError>

上传文件到 OSS Read more
Source§

fn put_content<F>( &self, content: Vec<u8>, path: Path, get_content_type: F, ) -> Result<String, FileError>
where F: Fn(&Vec<u8>) -> Option<&'static str>,

上传文件内容到 OSS Read more
Source§

fn put_content_base( &self, content: Vec<u8>, content_type: &str, path: Path, ) -> Result<Response, FileError>

最原始的上传文件的方法
Source§

fn get_object<Num, R>(&self, path: Path, range: R) -> Result<Vec<u8>, FileError>

获取文件内容 Read more
Source§

fn delete_object(&self, path: Path) -> Result<(), FileError>

删除 OSS 上的文件 Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<B> GetStdWithPath<&ObjectPathInner<'static>> for B
where B: AsRef<BucketBase>,

Source§

fn get_std_with_path( &self, path: &ObjectPathInner<'static>, ) -> Option<(Url, InnerCanonicalizedResource<'static>)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl<B> GetStdWithPath<&str> for B
where B: AsRef<BucketBase>,

Source§

fn get_std_with_path( &self, path: &str, ) -> Option<(Url, InnerCanonicalizedResource<'static>)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl<B> GetStdWithPath<ObjectPathInner<'static>> for B
where B: AsRef<BucketBase>,

Source§

fn get_std_with_path( &self, path: ObjectPathInner<'static>, ) -> Option<(Url, InnerCanonicalizedResource<'static>)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl<B> GetStdWithPath<String> for B
where B: AsRef<BucketBase>,

Source§

fn get_std_with_path( &self, path: String, ) -> Option<(Url, InnerCanonicalizedResource<'static>)>

根据 path 获取 UrlCanonicalizedResource
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,