mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
Integrate KeyboardHandler into ExplorerLayout to enable global keys - Memoize Explorer state flow (useCallback/useMemo) to reduce re-renders - Propagate selection state through GridView/FileCard via new SelectionContext props - Memoize TopBar using React.memo to prevent unnecessary updates
sd-client
Rust client library for connecting to the Spacedrive daemon.
Features
- Unix socket communication with Spacedrive core
- Type-safe query and action execution
- Media file listing queries
- Thumbnail URL construction
- Smart thumbnail variant selection
Usage
use sd_client::{SpacedriveClient, SdPath};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create client
let mut client = SpacedriveClient::new(
"/path/to/daemon.sock".into(),
"http://localhost:54321".into(),
);
// Set library context
client.set_library("library-uuid".to_string());
// Query media files
let files = client.media_listing(
SdPath::Physical {
device_id: "local".to_string(),
path: "/Users/you/Photos".to_string(),
},
Some(1000),
).await?;
// Get thumbnail URLs
for file in files {
if let Some(content_id) = file.content_identity {
if let Some(thumb) = client.select_best_thumbnail(&file.sidecars, 256.0) {
let url = client.thumbnail_url(
&content_id.uuid,
&thumb.variant,
&thumb.format,
);
println!("{}: {}", file.name, url);
}
}
}
Ok(())
}
Example
Run the test connection example:
export SD_LIBRARY_ID="your-library-uuid"
export SD_SOCKET_PATH="$HOME/.spacedrive/daemon.sock" # optional
export SD_HTTP_URL="http://127.0.0.1:54321" # optional
cargo run --example test_connection
API
SpacedriveClient
new(socket_path, http_base_url)- Create a new clientset_library(library_id)- Set the current library contextexecute(wire_method, input)- Execute a query or actionmedia_listing(path, limit)- Query media filesthumbnail_url(content_uuid, variant, format)- Construct thumbnail URLselect_best_thumbnail(sidecars, target_size)- Pick optimal thumbnail variant
Types
File- File metadata with content identity and sidecarsContentIdentity- Content hash and UUID for deduplicationSidecar- Generated derivatives (thumbnails, proxies, etc.)SdPath- Location-independent file referenceImageMediaData- Image-specific metadata (dimensions, date taken)VideoMediaData- Video-specific metadata (dimensions, duration)