tugraph/raw/index_spec.rs
1// Copyright 2023 antkiller
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 crate::ffi;
16
17use super::ffi_util;
18
19raw_pod_rustlize!(
20 RawIndexSpec,
21 lgraph_api_index_spec_t,
22 lgraph_api_index_spec_destroy,
23);
24
25impl RawIndexSpec {
26 pub(crate) fn label(&self) -> String {
27 unsafe {
28 let cstr = ffi::lgraph_api_index_spec_get_label(self.inner);
29 ffi_util::from_cstr(cstr)
30 }
31 }
32
33 pub(crate) fn field(&self) -> String {
34 unsafe {
35 let cstr = ffi::lgraph_api_index_spec_get_field(self.inner);
36 ffi_util::from_cstr(cstr)
37 }
38 }
39
40 pub(crate) fn unique(&self) -> bool {
41 unsafe { ffi::lgraph_api_index_spec_get_unique(self.inner) }
42 }
43}