forked from launchbadge/hedera-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_info.rs
39 lines (33 loc) · 825 Bytes
/
file_info.rs
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
use crate::PyDateTime;
use derive_more::From;
use hedera::FileInfo;
use pyo3::prelude::*;
use try_from::TryInto;
#[pyclass(name = FileInfo)]
#[derive(From)]
pub struct PyFileInfo {
inner: FileInfo,
}
#[pymethods]
impl PyFileInfo {
#[getter]
pub fn file_id(&mut self) -> PyResult<String> {
Ok(self.inner.file_id.to_string())
}
#[getter]
pub fn size(&mut self) -> PyResult<i64> {
Ok(self.inner.size)
}
#[getter]
pub fn deleted(&mut self) -> PyResult<bool> {
Ok(self.inner.deleted)
}
#[getter]
pub fn keys(&mut self) -> PyResult<Vec<String>> {
Ok(self.inner.keys.iter().map(|key| key.to_string()).collect())
}
#[getter]
pub fn expiration_time(&self) -> PyResult<PyDateTime> {
self.inner.expiration_time.try_into()
}
}