Skip to main content

adk_anthropic/types/
file_object.rs

1use serde::{Deserialize, Serialize};
2
3/// A file object returned by the Files API.
4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5pub struct FileObject {
6    /// Unique file identifier.
7    pub id: String,
8    /// Original filename.
9    pub filename: String,
10    /// Unix timestamp of creation.
11    pub created_at: i64,
12    /// File size in bytes.
13    pub size: u64,
14    /// Purpose of the file (e.g. "assistants").
15    pub purpose: String,
16}
17
18#[cfg(test)]
19mod tests {
20    use super::*;
21    use serde_json::json;
22
23    #[test]
24    fn roundtrip() {
25        let obj = FileObject {
26            id: "file-abc123".to_string(),
27            filename: "document.pdf".to_string(),
28            created_at: 1700000000,
29            size: 1024,
30            purpose: "assistants".to_string(),
31        };
32        let json = serde_json::to_value(&obj).unwrap();
33        assert_eq!(
34            json,
35            json!({
36                "id": "file-abc123",
37                "filename": "document.pdf",
38                "created_at": 1700000000,
39                "size": 1024,
40                "purpose": "assistants"
41            })
42        );
43        let deserialized: FileObject = serde_json::from_value(json).unwrap();
44        assert_eq!(obj, deserialized);
45    }
46}