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 formatter;
25pub mod json_node;
26pub mod parser;
27pub mod query;
28pub mod settings;
29pub mod types;
30
31pub use json_node::{JsonNode, KeyValuePair};
32pub use types::{
33 AppSettings, CompletionItem, Diagnostic, FoldingStyle, FormatOptions, LineEnding, LintOptions,
34 ParserOptions, Severity, Span,
35};
36
37// Re-export public API functions
38pub use completion::completions_at;
39pub use formatter::{format, minify};
40pub use parser::{diagnostics, parse, tolerant_parse};
41pub use query::{diagnostics_for_path, evaluate_path};
42pub use settings::{Settings, get_settings, set_in_memory_settings, update_settings};
43
44uniffi::setup_scaffolding!();
45
46/// A trivial ping-pong function to verify the UniFFI FFI bridge is working end-to-end.
47///
48/// # Arguments
49///
50/// * `input` - A string parameter sent from the calling shell (Swift/Kotlin).
51///
52/// # Returns
53///
54/// A formatted string response showing success.
55#[uniffi::export]
56pub fn ping(input: String) -> String {
57 format!("pong: {}", input)
58}
59
60#[cfg(test)]
61mod ffi_tests {
62 use super::*;
63
64 #[test]
65 fn test_ping_returns_pong_prefix() {
66 assert_eq!(ping("world".to_string()), "pong: world");
67 }
68
69 #[test]
70 fn test_ping_empty_string() {
71 assert_eq!(ping(String::new()), "pong: ");
72 }
73}