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
33
34
35
36
37
38
39
40
41
42
43
use {
	super::CSVDatabase,
	crate::{AutoIncrement, Result, WIPError},
	async_trait::async_trait,
	linecount::count_lines,
};

#[async_trait(?Send)]
impl AutoIncrement for CSVDatabase {
	async fn generate_increment_values(
		&mut self,
		_table_name: String,
		columns: Vec<(
			usize,  /*index*/
			String, /*name*/
			i64,    /*row_count*/
		) /*column*/>,
	) -> Result<
		Vec<(
			/*column*/ (usize /*index*/, String /*name*/),
			/*start_value*/ i64,
		)>,
	> {
		let lines: i64 = count_lines(
			std::fs::File::open(self.path.as_str())
				.map_err(|error| WIPError::Debug(format!("{:?}", error)))?,
		)
		.map_err(|error| WIPError::Debug(format!("{:?}", error)))? as i64;
		Ok(columns
			.into_iter()
			.map(|(index, name, _)| ((index, name), lines))
			.collect())
	}

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