Skip to main content

spatialrust_io/
traits.rs

1use spatialrust_core::{PointCloud, PointSchema, SpatialMetadata, SpatialResult};
2
3use crate::{ReadOptions, WriteOptions};
4
5/// Reads a point cloud from a file or stream.
6pub trait PointReader {
7    /// Returns the schema declared by the source.
8    fn schema(&self) -> SpatialResult<PointSchema>;
9
10    /// Returns spatial metadata associated with the source.
11    fn metadata(&self) -> SpatialResult<SpatialMetadata>;
12
13    /// Reads the full point cloud.
14    fn read(&mut self, options: &ReadOptions) -> SpatialResult<PointCloud>;
15}
16
17/// Writes a point cloud to a file or stream.
18pub trait PointWriter {
19    /// Writes the point cloud using the provided options.
20    fn write(&mut self, cloud: &PointCloud, options: &WriteOptions) -> SpatialResult<()>;
21}
22
23/// Reads point clouds in chunks.
24pub trait PointStream {
25    /// Advances to the next chunk, returning `false` when finished.
26    fn next_chunk(&mut self, options: &ReadOptions) -> SpatialResult<bool>;
27}
28
29/// Accepts point cloud chunks for streaming writes.
30pub trait PointSink {
31    /// Accepts one chunk for writing.
32    fn write_chunk(&mut self, cloud: &PointCloud, options: &WriteOptions) -> SpatialResult<()>;
33}