Skip to main content

zlink_names/
lib.rs

1//! Varlink names and their validation.
2//!
3//! Varlink names fields, types and interfaces each by their own rule. This crate provides a type
4//! for each kind of name, which can only hold a valid one, along with functions that check whether
5//! a string is a valid name. It is standalone: it does not pull in the rest of zlink.
6//!
7//! # Features
8//!
9//! * `serde`: The name types implement serde's `Serialize` and `Deserialize`. A name serializes as
10//!   a string, and a string is checked when it is deserialized into a name.
11//!
12//! # Examples
13//!
14//! ```
15//! use zlink_names::{InterfaceName, is_valid_type_name};
16//!
17//! let name = InterfaceName::try_from("org.example.Foo")?;
18//! assert_eq!(name, "org.example.Foo");
19//! assert!(InterfaceName::try_from("Foo").is_err());
20//! assert!(!is_valid_type_name("fileNotFound"));
21//! # Ok::<(), zlink_names::Error>(())
22//! ```
23#![cfg_attr(not(test), no_std)]
24#![doc(
25    html_logo_url = "https://raw.githubusercontent.com/z-galaxy/zlink/3660d731d7de8f60c8d82e122b3ece15617185e4/data/logo.png"
26)]
27#![deny(
28    missing_debug_implementations,
29    nonstandard_style,
30    rust_2018_idioms,
31    missing_docs
32)]
33#![warn(unreachable_pub, clippy::std_instead_of_core)]
34#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
35
36extern crate alloc;
37
38#[macro_use]
39mod macros;
40
41mod error;
42pub use error::Error;
43
44mod field_name;
45pub use field_name::{FieldName, OwnedFieldName, is_valid_field_name};
46
47mod type_name;
48pub use type_name::{OwnedTypeName, TypeName, is_valid_type_name};
49
50mod interface_name;
51pub use interface_name::{InterfaceName, OwnedInterfaceName, is_valid_interface_name};
52
53#[cfg(feature = "serde")]
54mod de;
55
56#[doc(hidden)]
57pub mod parse;