recoco_utils/db.rs
1// ReCoco is a Rust-only fork of CocoIndex, by [CocoIndex](https://CocoIndex)
2// Original code from CocoIndex is copyrighted by CocoIndex
3// SPDX-FileCopyrightText: 2025-2026 CocoIndex (upstream)
4// SPDX-FileContributor: CocoIndex Contributors
5//
6// All modifications from the upstream for ReCoco are copyrighted by Knitli Inc.
7// SPDX-FileCopyrightText: 2026 Knitli Inc. (ReCoco)
8// SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
9//
10// Both the upstream CocoIndex code and the ReCoco modifications are licensed under the Apache-2.0 License.
11// SPDX-License-Identifier: Apache-2.0
12
13pub enum WriteAction {
14 Insert,
15 Update,
16}
17
18pub fn sanitize_identifier(s: &str) -> String {
19 let mut result = String::new();
20 for c in s.chars() {
21 if c.is_alphanumeric() || c == '_' {
22 result.push(c);
23 } else {
24 result.push_str("__");
25 }
26 }
27 result
28}