#![cfg_attr(doc, doc = include_str!("../README.md"))]
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
pub mod protocol;
pub use protocol::{
EncodedPng, MAX_MESSAGE_BYTES, PROTOCOL_MAGIC, PROTOCOL_VERSION, Request, Response,
read_message, write_message,
};
pub const INSPECTION_ENV_VAR: &str = "EGUI_INSPECTION";
pub const DEFAULT_INSPECTION_ADDR: &str = "127.0.0.1:5719";
#[cfg(feature = "png")]
mod png;
#[cfg(feature = "plugin")]
mod plugin;
#[cfg(feature = "plugin")]
pub use plugin::InspectionPlugin;
#[cfg(all(feature = "plugin", not(target_arch = "wasm32")))]
pub use plugin::{attach_from_env, serve};
#[cfg(feature = "plugin")]
pub fn bind_addr_from_env() -> Option<String> {
let value = std::env::var(INSPECTION_ENV_VAR).ok()?;
match value.trim() {
"" | "0" => None,
v if v.eq_ignore_ascii_case("false") => None,
"1" => Some(DEFAULT_INSPECTION_ADDR.to_owned()),
v if v.eq_ignore_ascii_case("true") => Some(DEFAULT_INSPECTION_ADDR.to_owned()),
addr => Some(addr.to_owned()),
}
}