rs_pcd/storage/
view.rs

1// Copyright 2025 bigpear0201
2
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6
7//     http://www.apache.org/licenses/LICENSE-2.0
8
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::collections::HashMap;
16
17#[derive(Debug, Clone, Copy)]
18pub enum ColumnView<'a> {
19    U8(&'a [u8]),
20    U16(&'a [u16]),
21    U32(&'a [u32]),
22    I8(&'a [i8]),
23    I16(&'a [i16]),
24    I32(&'a [i32]),
25    F32(&'a [f32]),
26    F64(&'a [f64]),
27}
28
29impl<'a> ColumnView<'a> {
30    pub fn len(&self) -> usize {
31        match self {
32            ColumnView::U8(v) => v.len(),
33            ColumnView::U16(v) => v.len(),
34            ColumnView::U32(v) => v.len(),
35            ColumnView::I8(v) => v.len(),
36            ColumnView::I16(v) => v.len(),
37            ColumnView::I32(v) => v.len(),
38            ColumnView::F32(v) => v.len(),
39            ColumnView::F64(v) => v.len(),
40        }
41    }
42}
43
44pub struct PointView<'a> {
45    pub columns: HashMap<String, ColumnView<'a>>,
46    pub len: usize,
47}
48
49impl<'a> PointView<'a> {
50    pub fn new() -> Self {
51        Self {
52            columns: HashMap::new(),
53            len: 0,
54        }
55    }
56}