pub struct PutOperation<'a> { /* private fields */ }
Expand description
Represents an in-progress PUT Operation. Defined in OBEX 1.5 Section 3.4.3.
Example Usage:
let obex_client = ObexClient::new(..);
let put_operation = obex_client.put()?;
let user_data: Vec<u8> = vec![];
for user_data_chunk in user_data.chunks(50) {
let received_headers = put_operation.write(&user_data_chunk[..], HeaderSet::new()).await?;
}
// `PutOperation::write_final` must be called before it is dropped. An empty payload is OK.
let final_headers = put_operation.write_final(&[], HeaderSet::new()).await?;
// PUT operation is complete and `put_operation` is consumed.
Implementations§
Source§impl<'a> PutOperation<'a>
impl<'a> PutOperation<'a>
pub fn new(headers: HeaderSet, transport: ObexTransport<'a>) -> Self
Sourcepub async fn delete(self, headers: HeaderSet) -> Result<HeaderSet, Error>
pub async fn delete(self, headers: HeaderSet) -> Result<HeaderSet, Error>
Attempts to delete an object from the remote OBEX server specified by the provided
headers
.
Returns the informational headers from the peer response on success, Error otherwise.
Sourcepub async fn write(
&mut self,
data: &[u8],
headers: HeaderSet,
) -> Result<HeaderSet, Error>
pub async fn write( &mut self, data: &[u8], headers: HeaderSet, ) -> Result<HeaderSet, Error>
Attempts to write the data
object to the remote OBEX server.
Returns the informational headers from the peer response on success, Error otherwise.
The returned informational headers will be empty if Single Response Mode is enabled for the
operation. Only the final write request (Self::write_final
) will potentially return a
non-empty set of headers.
Sourcepub async fn write_final(
self,
data: &[u8],
headers: HeaderSet,
) -> Result<HeaderSet, Error>
pub async fn write_final( self, data: &[u8], headers: HeaderSet, ) -> Result<HeaderSet, Error>
Attempts to write the final data
object to the remote OBEX server.
This must be called before the PutOperation object is dropped.
Returns the informational headers from the peer response on success, Error otherwise.
The PUT operation is considered complete after this.
Sourcepub async fn terminate(self, headers: HeaderSet) -> Result<HeaderSet, Error>
pub async fn terminate(self, headers: HeaderSet) -> Result<HeaderSet, Error>
Request to terminate a multi-packet PUT request early. Returns the informational headers from the peer response on success, Error otherwise. If Error is returned, there are no guarantees about the synchronization between the local OBEX client and remote OBEX server.