jsonette/lib.rs
1/*
2 * Copyright (c) 2026 DevEtte.
3 *
4 * This project is dual-licensed under both the MIT License and the
5 * Apache License, Version 2.0 (the "License"). You may not use this
6 * file except in compliance with one of these licenses.
7 *
8 * You may obtain a copy of the Licenses at:
9 * - MIT: https://opensource.org
10 * - Apache 2.0: http://apache.org
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19//! Shell owns rendering only. All logic lives here.
20
21#![allow(unused_variables)]
22
23pub mod completion;
24pub mod converter;
25pub mod formatter;
26pub mod generator;
27pub mod json_node;
28pub mod parser;
29pub mod query;
30pub mod settings;
31pub mod types;
32
33pub use json_node::{JsonNode, KeyValuePair};
34pub use types::{
35 AppSettings, CompletionItem, Diagnostic, FoldingStyle, FormatOptions, LineEnding, LintOptions,
36 ParserOptions, Severity, Span,
37};
38
39// Re-export public API functions
40pub use completion::completions_at;
41pub use formatter::{format, minify};
42pub use parser::{diagnostics, parse, tolerant_parse};
43pub use query::{diagnostics_for_path, evaluate_path};
44pub use settings::{Settings, get_settings, set_in_memory_settings, update_settings};
45
46uniffi::setup_scaffolding!();
47
48/// A trivial ping-pong function to verify the UniFFI FFI bridge is working end-to-end.
49///
50/// # Arguments
51///
52/// * `input` - A string parameter sent from the calling shell (Swift/Kotlin).
53///
54/// # Returns
55///
56/// A formatted string response showing success.
57#[uniffi::export]
58pub fn ping(input: String) -> String {
59 format!("pong: {}", input)
60}
61
62#[cfg(test)]
63mod ffi_tests {
64 use super::*;
65
66 #[test]
67 fn test_ping_returns_pong_prefix() {
68 assert_eq!(ping("world".to_string()), "pong: world");
69 }
70
71 #[test]
72 fn test_ping_empty_string() {
73 assert_eq!(ping(String::new()), "pong: ");
74 }
75}