sevensense-core
Shared domain primitives for the 7sense bioacoustic intelligence platform.
sevensense-core provides the foundational types, traits, and utilities used across all 7sense crates. It defines the core vocabulary of the domain—species identifiers, temporal boundaries, audio metadata, and error types—ensuring consistency throughout the platform.
Features
- Species Taxonomy: Type-safe species identifiers with scientific/common name support
- Temporal Primitives: Time ranges, segments, and duration utilities for audio analysis
- Domain Events: Event-sourced primitives for audit trails and streaming
- Error Handling: Unified error types with rich context and error chains
- Configuration: Shared configuration primitives and validation
Use Cases
| Use Case | Description | Example Types |
|---|---|---|
| Species Management | Track and validate bird species | SpeciesId, TaxonomicRank, SpeciesMetadata |
| Time Handling | Represent audio segments and recordings | TimeRange, SegmentBounds, Duration |
| Audio Metadata | Describe recordings and their properties | RecordingId, AudioMetadata, Location |
| Error Propagation | Consistent error handling across crates | CoreError, ErrorContext, Result<T> |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
// Create a species identifier
let species = from_scientific;
println!;
// Define a time range for analysis
let range = new;
println!;
Creating Species Identifiers
use ;
// From scientific name
let blackbird = from_scientific;
// With common name
let blackbird = new;
// Check taxonomic information
assert_eq!;
assert_eq!;
Species Collections
use ;
let mut registry = new;
registry.register;
registry.register;
// Search by partial name
let thrushes = registry.search;
println!;
Basic Time Ranges
use TimeRange;
use ;
// Create a range for the last hour
let now = now;
let range = new;
// Check duration
println!;
// Check if a timestamp is within range
let test_time = now - minutes;
assert!;
Splitting Time Ranges
use TimeRange;
use Duration;
let range = last_n_hours;
// Split into 1-hour windows
let windows = range.split_by_duration;
println!;
// Split into equal parts
let parts = range.split_into_n_parts;
assert_eq!;
Using Core Errors
use ;
Error Chains
use ;
API Overview
Core Types
| Type | Description |
|---|---|
SpeciesId |
Unique identifier for a bird species |
RecordingId |
UUID-based recording identifier |
TimeRange |
Start/end time boundary |
Location |
Geographic coordinates (lat/lon) |
AudioMetadata |
Recording metadata (format, channels, etc.) |
Traits
| Trait | Description |
|---|---|
Identifiable |
Types with unique identifiers |
Timestamped |
Types with timestamp information |
Bounded |
Types with time boundaries |
License
MIT License - see LICENSE for details.