#![doc = include_str!("../README.md")]
use std::{ops::RangeInclusive, time::Duration};
mod budget_vec;
#[doc(hidden)]
pub mod budgeted_prost;
mod convert;
mod decode_budget;
mod frame;
mod generated;
#[cfg(feature = "python")]
pub mod python;
mod requirement;
#[cfg(feature = "test-util")]
#[doc(hidden)]
pub mod test_util;
mod wire;
#[cfg(feature = "worker")]
pub mod worker;
pub const PROTOCOL_VERSION: u32 = 5;
pub const MIN_SUPPORTED_PROTOCOL_VERSION: u32 = 5;
pub const DEFAULT_PRINT_FLUSH_INTERVAL: Duration = Duration::from_millis(5);
const _: () = assert!(MIN_SUPPORTED_PROTOCOL_VERSION >= 1);
const _: () = assert!(MIN_SUPPORTED_PROTOCOL_VERSION <= PROTOCOL_VERSION);
const SUPPORTED_PROTOCOL_VERSIONS: RangeInclusive<u32> = MIN_SUPPORTED_PROTOCOL_VERSION..=PROTOCOL_VERSION;
pub fn check_protocol_version(version: u32) -> Result<(), String> {
if SUPPORTED_PROTOCOL_VERSIONS.contains(&version) {
Ok(())
} else {
let supported = if MIN_SUPPORTED_PROTOCOL_VERSION == PROTOCOL_VERSION {
format_args!("server supports protocol version {PROTOCOL_VERSION}")
} else {
format_args!("server supports protocol versions {MIN_SUPPORTED_PROTOCOL_VERSION} to {PROTOCOL_VERSION}")
};
let tip = if version < MIN_SUPPORTED_PROTOCOL_VERSION {
"try updating to a newer client version"
} else {
"make sure you are using the correct client version"
};
Err(format!("unsupported protocol version {version} ({supported}, {tip})"))
}
}
pub use budget_vec::BudgetVec;
pub use convert::{
ProtoConvertError, ext_result_from_proto, ext_result_to_proto, future_results_from_proto, future_results_to_proto,
named_values_from_proto, named_values_to_proto, os_call_from_proto, os_call_to_proto, resume_call_from_proto,
};
#[cfg(feature = "test-util")]
#[doc(hidden)]
pub use decode_budget::{decode_budget_remaining, with_decode_budget};
pub use frame::{
DEFAULT_MAX_DECODE_BYTES, FrameError, FrameReader, MAX_FRAME_LEN, decode_frame, encode_framed_into,
encode_to_capped_vec, exceeds_max_frame_len, write_frame,
};
pub use generated::pb;
pub use requirement::validate_requirement;
pub use wire::{WireArena, WireFunctionCall, WireIndexes, WireNamedTuple, WireNodePairs};