mirror of
https://github.com/TrustTunnel/TrustTunnel.git
synced 2026-04-28 11:49:56 +00:00
Squashed commit of the following:
commit 598aeaf5aab09665f0de8248e58cef3866e97a5d
Author: Sergey Fionov <sfionov@adguard.com>
Date: Mon Apr 6 16:10:15 2026 +0300
Add example to README.md
commit 0b4e26b115
Author: Sergey Fionov <sfionov@adguard.com>
Date: Fri Apr 3 20:40:30 2026 +0300
Fix
commit c092ab370d
Author: Sergey Fionov <sfionov@adguard.com>
Date: Fri Apr 3 20:37:53 2026 +0300
TRUST-473 Add name and dns_servers to deep-link
49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
//! TrustTunnel Deep-Link Library
|
|
//!
|
|
//! This library provides encoding and decoding functionality for TrustTunnel
|
|
//! deep-link URIs (`tt://?` scheme). Deep-links allow compact, shareable
|
|
//! configuration URIs that can be used across platforms (mobile, desktop, CLI).
|
|
//!
|
|
|
|
pub mod cert;
|
|
pub mod decode;
|
|
pub mod encode;
|
|
pub mod error;
|
|
pub mod types;
|
|
pub mod varint;
|
|
|
|
pub use error::{DeepLinkError, Result};
|
|
pub use types::{DeepLinkConfig, DeepLinkConfigBuilder, Protocol, TlvTag, CURRENT_VERSION};
|
|
|
|
// Re-export varint functions for testing
|
|
pub use varint::{decode_varint, encode_varint};
|
|
|
|
/// Encode a configuration into a deep-link URI (`tt://?...`).
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// Returns `DeepLinkError` if encoding fails.
|
|
pub fn encode(config: &DeepLinkConfig) -> Result<String> {
|
|
encode::encode(config)
|
|
}
|
|
|
|
/// Decode a deep-link URI into a configuration.
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// Returns `DeepLinkError` if decoding fails.
|
|
pub fn decode(uri: &str) -> Result<DeepLinkConfig> {
|
|
decode::decode(uri)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_lib_exports() {
|
|
// Verify main types are exported
|
|
let _: fn(&DeepLinkConfig) -> Result<String> = encode;
|
|
let _: fn(&str) -> Result<DeepLinkConfig> = decode;
|
|
}
|
|
}
|