Skip to main content

squigit_storage/
lib.rs

1// Copyright 2026 a7mddra
2// SPDX-License-Identifier: Apache-2.0
3
4//! Content Addressable Storage (CAS) for images and thread data.
5//!
6//! This crate provides a Git-like storage system for the Squigit application,
7//! storing images by their BLAKE3 hash (deduplication) and managing thread data
8//! with persistent storage.
9//!
10//! # Example
11//!
12//! ```no_run
13//! use squigit_storage::{ThreadStorage, ThreadMetadata, ThreadData};
14//!
15//! let storage = ThreadStorage::new().unwrap();
16//!
17//! // Store an image
18//! let image_bytes = std::fs::read("screenshot.png").unwrap();
19//! let stored = storage.store_image(&image_bytes, None).unwrap();
20//! println!("Image hash: {}", stored.hash);
21//! println!("Image path: {}", stored.path);
22//!
23//! // Create a thread
24//! let metadata = ThreadMetadata::new("My Analysis".to_string(), stored.hash);
25//! let initial = storage.attachment_manifest_entry(&metadata.image_hash, "squigitshot.png", chrono::Utc::now()).unwrap();
26//! let thread = ThreadData::new(metadata, initial);
27//! storage.save_thread(&thread).unwrap();
28//! ```
29
30pub mod cas;
31pub mod error;
32pub mod paths;
33pub mod profiles;
34pub mod rules;
35mod secure_file;
36pub mod threads;
37pub mod version;
38
39pub use cas::{
40    AttachmentFileType, DocumentConversion, ObjectFileContext, ObjectManifest, ObjectManifestLock,
41    ObjectRemote, ReverseImageSearchCache, StoredImage, OBJECT_MANIFEST_SCHEMA_VERSION,
42};
43pub use error::{Result, StorageError};
44pub use profiles::{
45    canonical_google_issuer, EncryptedKeyRecord, KeyFile, KeyStoreTransaction, LastLogin, Profile,
46    ProfileAuth, ProfileIdentity, ProfileKeyRecords, ProfileSnapshot, ProfileStore, RecordCipher,
47    RecordKdf, AUTH_MODE_GOOGLE_OIDC_PKCE, AUTH_SCHEMA_VERSION, GOOGLE_ISSUER,
48    GOOGLE_PROFILE_ID_PREFIX, GOOGLE_PROVIDER, KEY_FILE_SCHEMA_VERSION,
49};
50pub use threads::{
51    AttachmentManifest, AttachmentManifestEntry, ContextWindow, MessageAttachment,
52    OcrAnnotationEntry, OcrAnnotations, OcrModelAnnotation, OcrRegion, SideChatData,
53    SideChatMetadata, ThreadData, ThreadMessage, ThreadMetadata, ThreadStorage, WorkspaceMetadata,
54    DEFAULT_SIDE_CHAT_TITLE, DEFAULT_THREAD_TITLE, EMPTY_STATE_ASSET_ID,
55};
56pub use version::{
57    ProductVersion, VersionFile, VersionStore, VersionStoreGuard, VersionType, VERSION_FILE_NAME,
58};