1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use {
	crate::{AutoIncrement, Result, SheetDatabase, SheetDatabaseError},
	async_trait::async_trait,
};

#[async_trait(?Send)]
impl AutoIncrement for SheetDatabase {
	async fn generate_increment_values(
		&mut self,
		sheet_name: String,
		columns: Vec<(usize, String, i64)>,
	) -> Result<Vec<((usize, String), i64)>> {
		let sheet = self
			.book
			.get_sheet_by_name_mut(&sheet_name)
			.map_err(|_| SheetDatabaseError::FailedToGetSheet)?;
		let row_init = sheet.get_row_dimensions().len();
		Ok(columns
			.into_iter()
			.map(|(index, name, _)| ((index, name), row_init as i64))
			.collect())
	}

	async fn set_increment_value(
		&mut self,
		_table_name: &str,
		_column_name: &str,
		_end: i64,
	) -> Result<()> {
		Ok(())
	}
}