hyperscan-async 0.0.0

Async wrapper for the hyperscan C++ regex library.
/* Copyright 2022-2023 Danny McClanahan */
/* SPDX-License-Identifier: BSD-3-Clause */

//! ???

// Warn for missing docs in general, and hard require crate-level docs.
// #![warn(missing_docs)]
#![warn(rustdoc::missing_crate_level_docs)]
/* Make all doctests fail if they produce any warnings. */
#![doc(test(attr(deny(warnings))))]

mod bindings {
  include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
pub(crate) use bindings::root as hs;

pub mod alloc;
pub mod database;
pub mod error;
pub mod expression;
pub mod flags;
pub mod matchers;
pub mod state;
pub mod stream;

///```
/// # fn main() -> Result<(), hyperscan_async::error::HyperscanError> {
/// hyperscan_async::check_valid_platform()?;
/// # Ok(())
/// # }
/// ```
pub fn check_valid_platform() -> Result<(), error::HyperscanError> {
  error::HyperscanError::from_native(unsafe { hs::hs_valid_platform() })
}

///```
/// let v = hyperscan_async::version().to_str().unwrap();
/// assert!(v.starts_with("5.4.2 2023"));
/// ```
pub fn version() -> &'static std::ffi::CStr {
  unsafe { std::ffi::CStr::from_ptr(hs::hs_version()) }
}