#![cfg_attr(not(feature = "std"), no_std)]
#![deny(unsafe_code)]
#![warn(missing_docs)]
extern crate alloc;
pub mod address;
pub mod error;
pub mod message;
pub mod service;
#[cfg(feature = "std")]
pub mod sync;
pub mod types;
pub mod username;
pub mod wire;
pub use address::{Address, AddressError};
pub use error::{Error, Result};
pub use message::{
ContentType, ForwardInfo, MediaMetadata, Message, MessageId, MessagePriority, ReplyContext,
WireCodec,
};
pub use service::{ServiceDescriptor, ServiceId};
#[cfg(feature = "std")]
pub use sync::{MutexExt, RwLockExt};
#[cfg(feature = "std")]
pub use types::LocalInstant;
pub use types::{
validate_id_chars, AppId, HopCount, IdValidationError, LamportClock, MetadataMap, Timestamp,
UserId, WallClockTimestamp, MAX_ID_LEN, TTL,
};
pub use username::{contains_control_or_format, Username, UsernameError};
pub use wire::{WIRE_V1_MAGIC, WIRE_VERSION_V1};
#[cfg(all(test, feature = "std"))]
mod manifest_guard_tests {
const LOCAL_DEPS: &[&str] = &[
"serde",
"serde_json",
"base64",
"unicode-normalization",
"thiserror",
"uuid",
"tracing",
];
fn version_req(manifest: &str, name: &str) -> Option<String> {
let line = manifest
.lines()
.find(|l| l.starts_with(&format!("{name} = ")))?;
let rest = match line.find("version = \"") {
Some(i) => &line[i + "version = \"".len()..],
None => {
let i = line.find('"')?;
&line[i + 1..]
}
};
rest.find('"').map(|end| rest[..end].to_string())
}
#[test]
fn local_dep_versions_match_the_workspace_table() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let root = dir.join("../../Cargo.toml");
let Ok(root_manifest) = std::fs::read_to_string(&root) else {
return;
};
let own_manifest =
std::fs::read_to_string(dir.join("Cargo.toml")).expect("own manifest is readable");
for dep in LOCAL_DEPS {
let workspace = version_req(&root_manifest, dep)
.unwrap_or_else(|| panic!("`{dep}` not found in the workspace dependency table"));
let own = version_req(&own_manifest, dep)
.unwrap_or_else(|| panic!("`{dep}` not found in this crate's manifest"));
assert_eq!(
workspace, own,
"`{dep}` version drifted: workspace says {workspace:?}, \
offline-protocol-core says {own:?}. Update both together."
);
}
}
}