src/client/backup_reader.rs: add documentation

This commit is contained in:
Dietmar Maurer 2019-10-12 13:26:47 +02:00
parent 9e490a7479
commit 913acb41fd

View File

@ -11,7 +11,7 @@ use crate::tools::futures::Canceller;
use super::{HttpClient, H2Client}; use super::{HttpClient, H2Client};
/// Backup /// Backup Reader
pub struct BackupReader { pub struct BackupReader {
h2: H2Client, h2: H2Client,
canceller: Canceller, canceller: Canceller,
@ -30,6 +30,7 @@ impl BackupReader {
Arc::new(Self { h2, canceller }) Arc::new(Self { h2, canceller })
} }
/// Create a new instance by upgrading the connection at '/api2/json/reader'
pub async fn start( pub async fn start(
client: HttpClient, client: HttpClient,
datastore: &str, datastore: &str,
@ -53,6 +54,7 @@ impl BackupReader {
Ok(BackupReader::new(h2, canceller)) Ok(BackupReader::new(h2, canceller))
} }
/// Execute a GET request
pub async fn get( pub async fn get(
&self, &self,
path: &str, path: &str,
@ -61,6 +63,7 @@ impl BackupReader {
self.h2.get(path, param).await self.h2.get(path, param).await
} }
/// Execute a PUT request
pub async fn put( pub async fn put(
&self, &self,
path: &str, path: &str,
@ -69,6 +72,7 @@ impl BackupReader {
self.h2.put(path, param).await self.h2.put(path, param).await
} }
/// Execute a POST request
pub async fn post( pub async fn post(
&self, &self,
path: &str, path: &str,
@ -77,6 +81,7 @@ impl BackupReader {
self.h2.post(path, param).await self.h2.post(path, param).await
} }
/// Execute a GET request and send output to a writer
pub async fn download<W: Write + Send>( pub async fn download<W: Write + Send>(
&self, &self,
file_name: &str, file_name: &str,
@ -87,6 +92,9 @@ impl BackupReader {
self.h2.download(path, Some(param), output).await self.h2.download(path, Some(param), output).await
} }
/// Execute a special GET request and send output to a writer
///
/// This writes random data, and is only useful to test download speed.
pub async fn speedtest<W: Write + Send>( pub async fn speedtest<W: Write + Send>(
&self, &self,
output: W, output: W,
@ -94,6 +102,7 @@ impl BackupReader {
self.h2.download("speedtest", None, output).await self.h2.download("speedtest", None, output).await
} }
/// Download a specific chunk
pub async fn download_chunk<W: Write + Send>( pub async fn download_chunk<W: Write + Send>(
&self, &self,
digest: &[u8; 32], digest: &[u8; 32],