Skip to main content

edgequake_sdk/resources/
chunks.rs

1//! Chunks resource.
2
3use crate::client::EdgeQuakeClient;
4use crate::error::Result;
5use crate::types::operations::{ChunkDetail, ChunkLineageInfo};
6
7pub struct ChunksResource<'a> {
8    pub(crate) client: &'a EdgeQuakeClient,
9}
10
11impl<'a> ChunksResource<'a> {
12    /// `GET /api/v1/documents/{doc_id}/chunks`
13    pub async fn list(&self, document_id: &str) -> Result<Vec<ChunkDetail>> {
14        self.client
15            .get(&format!("/api/v1/documents/{document_id}/chunks"))
16            .await
17    }
18
19    /// `GET /api/v1/chunks/{id}`
20    pub async fn get(&self, id: &str) -> Result<ChunkDetail> {
21        self.client.get(&format!("/api/v1/chunks/{id}")).await
22    }
23
24    /// `GET /api/v1/chunks/{id}/lineage`
25    ///
26    /// Returns chunk lineage with parent document refs and position info.
27    /// @implements F3 — Every chunk contains parent_document_id and position info.
28    /// @implements F8 — PDF → Document → Chunk → Entity chain traceable.
29    pub async fn get_lineage(&self, id: &str) -> Result<ChunkLineageInfo> {
30        self.client
31            .get(&format!("/api/v1/chunks/{id}/lineage"))
32            .await
33    }
34}