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