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
44
45
46
47
48
49
50
51
52
53
use crate::models::{Attachment, Cell, Column, Discussion, User};
use crate::types::Result;
use core::option::Option;
use serde::{Deserialize, Serialize};
use std::io::{Error, ErrorKind};
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Row {
pub id: u64,
#[serde(rename = "sheet_id")]
pub sheet_id: Option<u64>,
#[serde(rename = "rowNumber")]
pub row_number: u64,
pub expanded: bool,
pub cells: Vec<Cell>,
#[serde(default)]
pub columns: Vec<Column>,
pub attachments: Option<Vec<Attachment>>,
pub discussions: Option<Vec<Discussion>>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "createdBy")]
pub created_by: Option<User>,
#[serde(rename = "modifiedAt")]
pub modified_at: String,
#[serde(rename = "siblingId")]
pub sibling_id: Option<u64>,
#[serde(rename = "filteredOut")]
pub filtered_out: Option<bool>,
pub format: Option<String>,
#[serde(rename = "modifiedBy")]
pub modified_by: Option<User>,
pub permalink: Option<String>,
#[serde(rename = "accessLevel")]
pub access_level: Option<String>,
pub version: Option<u64>,
}
impl Row {
pub fn get_cell_by_id(&self, column_id: u64) -> Result<&Cell> {
for cell in &self.cells {
if cell.column_id == column_id {
return Ok(cell);
}
}
Err(Box::from(Error::new(
ErrorKind::NotFound,
"No cell found for the given Column ID or Name",
)))
}
}