@@ -15,70 +15,70 @@ pub use objectstore_types::{Compression, ExpirationPolicy};
1515
1616use crate :: { ClientStream , Session } ;
1717
18- /// The response returned from the service after uploading an object.
18+ /// The response returned from the service after inserting an object.
1919#[ derive( Debug , Deserialize ) ]
20- pub struct PutResponse {
20+ pub struct InsertResponse {
2121 /// The key of the object, as stored.
2222 pub key : String ,
2323}
2424
25- pub ( crate ) enum PutBody {
25+ pub ( crate ) enum InsertBody {
2626 Buffer ( Bytes ) ,
2727 Stream ( ClientStream ) ,
2828}
2929
30- impl fmt:: Debug for PutBody {
30+ impl fmt:: Debug for InsertBody {
3131 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
32- f. debug_tuple ( "PutBody " ) . finish_non_exhaustive ( )
32+ f. debug_tuple ( "InsertBody " ) . finish_non_exhaustive ( )
3333 }
3434}
3535
3636impl Session {
37- fn put_body ( & self , body : PutBody ) -> PutBuilder {
37+ fn insert_body ( & self , body : InsertBody ) -> InsertBuilder {
3838 let metadata = Metadata {
3939 expiration_policy : self . scope . usecase ( ) . expiration_policy ( ) ,
4040 compression : Some ( self . scope . usecase ( ) . compression ( ) ) ,
4141 ..Default :: default ( )
4242 } ;
4343
44- PutBuilder {
44+ InsertBuilder {
4545 session : self . clone ( ) ,
4646 metadata,
4747 key : None ,
4848 body,
4949 }
5050 }
5151
52- /// Creates a PUT request for a [`Bytes`]-like type .
53- pub fn put ( & self , body : impl Into < Bytes > ) -> PutBuilder {
54- self . put_body ( PutBody :: Buffer ( body. into ( ) ) )
52+ /// Creates or replaces an object using a [`Bytes`]-like payload .
53+ pub fn insert ( & self , body : impl Into < Bytes > ) -> InsertBuilder {
54+ self . insert_body ( InsertBody :: Buffer ( body. into ( ) ) )
5555 }
5656
57- /// Creates a PUT request with a stream .
58- pub fn put_stream ( & self , body : ClientStream ) -> PutBuilder {
59- self . put_body ( PutBody :: Stream ( body) )
57+ /// Creates or replaces an object using a streaming payload .
58+ pub fn insert_stream ( & self , body : ClientStream ) -> InsertBuilder {
59+ self . insert_body ( InsertBody :: Stream ( body) )
6060 }
6161
62- /// Creates a PUT request with an [`AsyncRead`] type .
63- pub fn put_read < R > ( & self , body : R ) -> PutBuilder
62+ /// Creates or replaces an object using an [`AsyncRead`] payload .
63+ pub fn insert_read < R > ( & self , body : R ) -> InsertBuilder
6464 where
6565 R : AsyncRead + Send + Sync + ' static ,
6666 {
6767 let stream = ReaderStream :: new ( body) . boxed ( ) ;
68- self . put_body ( PutBody :: Stream ( stream) )
68+ self . insert_body ( InsertBody :: Stream ( stream) )
6969 }
7070}
7171
72- /// A PUT request builder.
72+ /// An insert request builder.
7373#[ derive( Debug ) ]
74- pub struct PutBuilder {
74+ pub struct InsertBuilder {
7575 session : Session ,
7676 metadata : Metadata ,
7777 key : Option < String > ,
78- body : PutBody ,
78+ body : InsertBody ,
7979}
8080
81- impl PutBuilder {
81+ impl InsertBuilder {
8282 /// Sets an explicit object key.
8383 ///
8484 /// If a key is specified, the object will be stored under that key. Otherwise, the Objectstore
@@ -135,9 +135,9 @@ impl PutBuilder {
135135// TODO: instead of a separate `send` method, it would be nice to just implement `IntoFuture`.
136136// However, `IntoFuture` needs to define the resulting future as an associated type,
137137// and "impl trait in associated type position" is not yet stable :-(
138- impl PutBuilder {
139- /// Sends the built PUT request to the upstream service.
140- pub async fn send ( self ) -> crate :: Result < PutResponse > {
138+ impl InsertBuilder {
139+ /// Sends the built insert request to the upstream service.
140+ pub async fn send ( self ) -> crate :: Result < InsertResponse > {
141141 let method = match self . key {
142142 Some ( _) => reqwest:: Method :: PUT ,
143143 None => reqwest:: Method :: POST ,
@@ -148,20 +148,20 @@ impl PutBuilder {
148148 . request ( method, self . key . as_deref ( ) . unwrap_or_default ( ) ) ;
149149
150150 let body = match ( self . metadata . compression , self . body ) {
151- ( Some ( Compression :: Zstd ) , PutBody :: Buffer ( bytes) ) => {
151+ ( Some ( Compression :: Zstd ) , InsertBody :: Buffer ( bytes) ) => {
152152 let cursor = Cursor :: new ( bytes) ;
153153 let encoder = ZstdEncoder :: new ( cursor) ;
154154 let stream = ReaderStream :: new ( encoder) ;
155155 Body :: wrap_stream ( stream)
156156 }
157- ( Some ( Compression :: Zstd ) , PutBody :: Stream ( stream) ) => {
157+ ( Some ( Compression :: Zstd ) , InsertBody :: Stream ( stream) ) => {
158158 let stream = StreamReader :: new ( stream) ;
159159 let encoder = ZstdEncoder :: new ( stream) ;
160160 let stream = ReaderStream :: new ( encoder) ;
161161 Body :: wrap_stream ( stream)
162162 }
163- ( None , PutBody :: Buffer ( bytes) ) => bytes. into ( ) ,
164- ( None , PutBody :: Stream ( stream) ) => Body :: wrap_stream ( stream) ,
163+ ( None , InsertBody :: Buffer ( bytes) ) => bytes. into ( ) ,
164+ ( None , InsertBody :: Stream ( stream) ) => Body :: wrap_stream ( stream) ,
165165 // _ => todo!("compression algorithms other than `zstd` are currently not supported"),
166166 } ;
167167
0 commit comments