diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-18 01:06:16 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-18 01:06:16 +0800 |
| commit | ebd46942c3fcc7939e5567a797a55198148301ea (patch) | |
| tree | ffa06c7d6af46bb0008426483d6db79dfa5ae4fb /rola-bucket | |
| parent | d2e4cb85af2c6101cd435c10cfd3d4084cd83e76 (diff) | |
refactor: rename `Info` and `TransferInfo` to `ExtraInfo`
Diffstat (limited to 'rola-bucket')
| -rw-r--r-- | rola-bucket/src/protocol.rs | 56 | ||||
| -rw-r--r-- | rola-bucket/src/protocol/local_fs.rs | 10 |
2 files changed, 33 insertions, 33 deletions
diff --git a/rola-bucket/src/protocol.rs b/rola-bucket/src/protocol.rs index 6d1074a..5523176 100644 --- a/rola-bucket/src/protocol.rs +++ b/rola-bucket/src/protocol.rs @@ -9,12 +9,12 @@ mod local_fs; pub use local_fs::*; /// Request used in [BucketTransferProtocol] or [AsyncBucketTransferProtocol] -pub struct UploadToBucketRequest<'a, Info> +pub struct UploadToBucketRequest<'a, ExtraInfo> where - Info: Clone + Sync + Send, + ExtraInfo: Clone + Sync + Send, { /// Extra data to record during the transfer process - pub extra_info: &'a Info, + pub extra_info: &'a ExtraInfo, /// The relative file path in the bucket to store the uploaded file pub relative_file_path_to_receive: &'a Path, @@ -24,12 +24,12 @@ where } /// Request used in [BucketTransferProtocol] or [AsyncBucketTransferProtocol] -pub struct DownloadFromBucketRequest<'a, Info> +pub struct DownloadFromBucketRequest<'a, ExtraInfo> where - Info: Clone + Sync + Send, + ExtraInfo: Clone + Sync + Send, { /// Extra data to record during the transfer process - pub extra_info: &'a Info, + pub extra_info: &'a ExtraInfo, /// The relative file path in the bucket to download pub relative_file_path_to_transfer: &'a Path, @@ -39,12 +39,12 @@ where } /// Request used in [BucketTransferProtocol] or [AsyncBucketTransferProtocol] -pub struct TransferToClientRequest<'a, Info> +pub struct TransferToClientRequest<'a, ExtraInfo> where - Info: Clone + Sync + Send, + ExtraInfo: Clone + Sync + Send, { /// Extra data to record during the transfer process - pub extra_info: &'a Info, + pub extra_info: &'a ExtraInfo, /// The relative file path for the client to download from the bucket pub relative_file_path_to_download: &'a Path, @@ -54,12 +54,12 @@ where } /// Request used in [BucketTransferProtocol] or [AsyncBucketTransferProtocol] -pub struct ReceiveFromClientRequest<'a, Info> +pub struct ReceiveFromClientRequest<'a, ExtraInfo> where - Info: Clone + Sync + Send, + ExtraInfo: Clone + Sync + Send, { /// Extra data to record during the transfer process - pub extra_info: &'a Info, + pub extra_info: &'a ExtraInfo, /// The relative file path in the bucket to store the uploaded file pub relative_file_path_to_upload: &'a Path, @@ -71,68 +71,68 @@ where /// This trait is used to implement the specific workflow of file transfer pub trait BucketTransferProtocol { /// Structure used to record transfer information - type TransferInfo: Clone + Sync + Send; + type ExtraInfo: Clone + Sync + Send; /// Upload a file to the storage bucket /// The caller must ensure that this function performs the actual transfer operation fn upload_to_bucket( &self, - req: &UploadToBucketRequest<Self::TransferInfo>, + req: &UploadToBucketRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError>; /// Download a file from the storage bucket /// The caller must ensure that after this function executes, a file (and only a file, not a directory) exists at the `path_to_save_file` path fn download_from_bucket( &self, - req: &DownloadFromBucketRequest<Self::TransferInfo>, + req: &DownloadFromBucketRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError>; /// Transfer a file to the client /// The caller must ensure that this function performs the actual transfer operation fn transfer_to_client( &self, - req: &TransferToClientRequest<Self::TransferInfo>, + req: &TransferToClientRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError>; /// Receive a file from the client /// The caller must ensure that after this function executes, a file (and only a file, not a directory) exists at the `path_to_save_file` path fn receive_from_client( &self, - req: &ReceiveFromClientRequest<Self::TransferInfo>, + req: &ReceiveFromClientRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError>; } /// This trait is used to implement the specific workflow of file transfer (asynchronous mode) pub trait AsyncBucketTransferProtocol { /// Structure used to record transfer information - type TransferInfo: Clone + Sync + Send; + type ExtraInfo: Clone + Sync + Send; /// Asynchronously upload a file to the storage bucket /// The caller must ensure that this function performs the actual transfer operation fn upload_to_bucket_async( &self, - req: &UploadToBucketRequest<Self::TransferInfo>, + req: &UploadToBucketRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync; /// Asynchronously download a file from the storage bucket /// The caller must ensure that after this function executes, a file (and only a file, not a directory) exists at the `path_to_save_file` path fn download_from_bucket_async( &self, - req: &DownloadFromBucketRequest<Self::TransferInfo>, + req: &DownloadFromBucketRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync; /// Asynchronously transfer a file to the client /// The caller must ensure that this function performs the actual transfer operation fn transfer_to_client_async( &self, - req: &TransferToClientRequest<Self::TransferInfo>, + req: &TransferToClientRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync; /// Asynchronously receive a file from the client /// The caller must ensure that after this function executes, a file (and only a file, not a directory) exists at the `path_to_save_file` path fn receive_from_client_async( &self, - req: &ReceiveFromClientRequest<Self::TransferInfo>, + req: &ReceiveFromClientRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync; } @@ -140,34 +140,34 @@ pub trait AsyncBucketTransferProtocol { /// `BucketTransferProtocol` methods by wrapping them in `async {}` blocks. impl<T: BucketTransferProtocol + Sync> AsyncBucketTransferProtocol for T where - T::TransferInfo: Sync, + T::ExtraInfo: Sync, { - type TransferInfo = T::TransferInfo; + type ExtraInfo = T::ExtraInfo; fn upload_to_bucket_async( &self, - req: &UploadToBucketRequest<Self::TransferInfo>, + req: &UploadToBucketRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync { async move { self.upload_to_bucket(req) } } fn download_from_bucket_async( &self, - req: &DownloadFromBucketRequest<Self::TransferInfo>, + req: &DownloadFromBucketRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync { async move { self.download_from_bucket(req) } } fn transfer_to_client_async( &self, - req: &TransferToClientRequest<Self::TransferInfo>, + req: &TransferToClientRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync { async move { self.transfer_to_client(req) } } fn receive_from_client_async( &self, - req: &ReceiveFromClientRequest<Self::TransferInfo>, + req: &ReceiveFromClientRequest<Self::ExtraInfo>, ) -> impl Future<Output = Result<(), BucketTransferProtocolError>> + Send + Sync { async move { self.receive_from_client(req) } } diff --git a/rola-bucket/src/protocol/local_fs.rs b/rola-bucket/src/protocol/local_fs.rs index b3885a7..ec8999b 100644 --- a/rola-bucket/src/protocol/local_fs.rs +++ b/rola-bucket/src/protocol/local_fs.rs @@ -24,11 +24,11 @@ pub enum LocalFileSystemProtocol { } impl BucketTransferProtocol for LocalFileSystemProtocol { - type TransferInfo = (); + type ExtraInfo = (); fn upload_to_bucket( &self, - req: &super::UploadToBucketRequest<Self::TransferInfo>, + req: &super::UploadToBucketRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError> { let ClientSide { bucket_root } = self else { // NOTE: As a local filesystem transfer protocol, @@ -44,7 +44,7 @@ impl BucketTransferProtocol for LocalFileSystemProtocol { fn download_from_bucket( &self, - req: &super::DownloadFromBucketRequest<Self::TransferInfo>, + req: &super::DownloadFromBucketRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError> { let ClientSide { bucket_root } = self else { // NOTE: As a local filesystem transfer protocol, @@ -60,7 +60,7 @@ impl BucketTransferProtocol for LocalFileSystemProtocol { fn transfer_to_client( &self, - req: &super::TransferToClientRequest<Self::TransferInfo>, + req: &super::TransferToClientRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError> { let BucketSide { client_root } = self else { // NOTE: As a local filesystem transfer protocol, @@ -76,7 +76,7 @@ impl BucketTransferProtocol for LocalFileSystemProtocol { fn receive_from_client( &self, - req: &super::ReceiveFromClientRequest<Self::TransferInfo>, + req: &super::ReceiveFromClientRequest<Self::ExtraInfo>, ) -> Result<(), BucketTransferProtocolError> { let BucketSide { client_root } = self else { // NOTE: As a local filesystem transfer protocol, |
