# Lattice SDK Rust Examples
✅ **All examples compile and are ready to use!**
## Quick Start
```bash
export LATTICE_API_KEY="your-key"
export LATTICE_BASE_URL="https://api.lattice.example.com"
cargo run --example simple_usage
```
## Available Examples
### 1. **simple_usage** - Basic Setup
```bash
cargo run --example simple_usage
```
Shows minimal client creation.
### 2. **entities_basic** - Entity CRUD
```bash
cargo run --example entities_basic
```
Complete entity operations: publish, retrieve with location/ontology data.
### 3. **entities_polling** - Real-Time Events
```bash
cargo run --example entities_polling
```
Long-polling for entity events (5-min timeout).
### 4. **tasks_basic** - Task Management
```bash
cargo run --example tasks_basic
```
Create and retrieve tasks. Note: task_id is at `task.version.task_id`
### 5. **objects_basic** - File Storage
```bash
cargo run --example objects_basic
```
Upload, list, download objects. Note: use `response.path_metadatas`
## Key Insights
### Response Field Names
- ✅ `ListResponse.path_metadatas` (not `.objects`)
- ✅ `EntityEventResponse.entity_events` (not `.events`)
- ✅ `Task.version.task_id` (nested)
### Type System
- Most types don't implement `Default`
- All Option fields must be explicit: `field: None`
### Error Handling
```rust
match result {
Ok(data) => { /* success */ }
Err(ApiError::RequestTimeoutError { .. }) => { /* timeout */ }
Err(e) => { /* other error */ }
}
```
## Documentation
- Main SDK: [../README.md](../README.md)
- Implementation notes: [../EXAMPLES_ADDED.md](../EXAMPLES_ADDED.md)
- Type definitions: `../src/api/types/`
**Status:** ✅ All 5 examples compile successfully