#![doc = include_str!("../README.md")]
#![deny(unused_must_use)]
#![deny(missing_docs)] #![deny(clippy::as_conversions)]
pub mod abilities;
pub mod camera;
pub mod context;
pub mod error;
pub mod file;
pub mod filesys;
pub(crate) mod helper;
pub mod list;
pub mod port;
pub mod task;
pub(crate) mod thread;
pub mod widget;
use std::ffi::CStr;
use self::error::try_gp_internal;
#[doc(inline)]
pub use crate::{
camera::Camera,
context::Context,
error::{Error, Result},
};
pub use libgphoto2_sys;
#[cfg(all(test, not(feature = "test")))]
compile_error!("The test feature must be enabled to run the tests");
pub fn library_version() -> Option<&'static str> {
unsafe {
CStr::from_ptr(*libgphoto2_sys::gp_library_version(
libgphoto2_sys::GPVersionVerbosity::GP_VERSION_SHORT,
))
.to_str()
.ok()
}
}
#[cfg(all(test, feature = "test"))]
fn sample_context() -> Context {
use std::sync::Once;
static INIT: Once = Once::new();
INIT.call_once(|| {
env_logger::builder()
.filter_module("gphoto2", log::LevelFilter::max())
.is_test(true)
.init();
libgphoto2_sys::test_utils::set_env();
});
Context::new().unwrap()
}
#[cfg(all(test, feature = "test"))]
#[test]
fn test_version() {
insta::assert_snapshot!(library_version().unwrap());
}