Skip to content

Commit 9c80c45

Browse files
committed
Add documentation
1 parent 56ae097 commit 9c80c45

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/dumps.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
1+
//! The `dumps` module allows the creation of database dumps.
2+
//! Dumps are `.dump` files that can be used to launch MeiliSearch.
3+
//! Dumps are compatible between MeiliSearch versions.
4+
//!
5+
//! Creating a dump is also referred to as exporting it, whereas launching MeiliSearch with a dump is referred to as importing it.
6+
//!
7+
//! During a [dump export](Client::create_dump), all [indexes](crate::indexes::Index) of the current instance are exported—together with their documents and settings—and saved as a single `.dump` file.
8+
//!
9+
//! During a dump import, all indexes contained in the indicated `.dump` file are imported along with their associated [documents](crate::document::Document) and [settings](crate::settings::Settings).
10+
//! Any existing [index](crate::indexes::Index) with the same uid as an index in the dump file will be overwritten.
11+
//!
12+
//! Dump imports are [performed at launch](https://docs.meilisearch.com/reference/features/configuration.html#import-dump) using an option.
13+
//! [Batch size](https://docs.meilisearch.com/reference/features/configuration.html#dump-batch-size) can also be set at this time.
14+
115
use crate::{client::Client, errors::Error, request::*};
216
use serde::Deserialize;
317

18+
/// The status of a dump.\
19+
/// Contained in [`DumpInfo`].
420
#[derive(Debug, Deserialize, Clone, PartialEq)]
521
#[serde(rename_all = "snake_case")]
622
pub enum DumpStatus {
23+
/// Dump creation is in progress.
724
Done,
25+
/// Dump creation is in progress.
826
InProgress,
27+
/// An error occured during dump process, and the task was aborted.
928
Failed,
1029
}
1130

31+
/// Limited informations about a dump.\
32+
/// Can be obtained with [create_dump](Client::create_dump) and [get_dump_status](Client::get_dump_status) methods.
1233
#[derive(Debug, Deserialize, Clone)]
1334
#[serde(rename_all = "camelCase")]
1435
pub struct DumpInfo {
@@ -17,7 +38,12 @@ pub struct DumpInfo {
1738
pub error: Option<serde_json::Value>,
1839
}
1940

41+
/// Dump related methods.\
42+
/// See the [dumps](crate::dumps) module.
2043
impl<'a> Client<'a> {
44+
/// Triggers a dump creation process.
45+
/// Once the process is complete, a dump is created in the [dumps directory](https://docs.meilisearch.com/reference/features/configuration.html#dumps-destination).
46+
/// If the dumps directory does not exist yet, it will be created.
2147
pub async fn create_dump(&self) -> Result<DumpInfo, Error> {
2248
request::<(), DumpInfo>(
2349
&format!("{}/dumps", self.host),
@@ -28,6 +54,7 @@ impl<'a> Client<'a> {
2854
.await
2955
}
3056

57+
/// Get the status of a dump creation process using [the uid](DumpInfo::uid) returned after calling the [dump creation method](Client::create_dump).
3158
pub async fn get_dump_status(&self, dump_uid: &str) -> Result<DumpInfo, Error> {
3259
request::<(), DumpInfo>(
3360
&format!("{}/dumps/{}/status", self.host, dump_uid),
@@ -38,3 +65,13 @@ impl<'a> Client<'a> {
3865
.await
3966
}
4067
}
68+
69+
/// Alias for [create_dump](Client::create_dump).
70+
pub async fn create_dump<'a>(client: &'a Client<'a>) -> Result<DumpInfo, Error> {
71+
client.create_dump().await
72+
}
73+
74+
/// Alias for [get_dump_status](Client::get_dump_status).
75+
pub async fn get_dump_status<'a>(client: &'a Client<'a>, dump_uid: &str) -> Result<DumpInfo, Error> {
76+
client.get_dump_status(dump_uid).await
77+
}

0 commit comments

Comments
 (0)