Skip to content

Commit

Permalink
Try to get documentation to build on docs.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosmann committed May 4, 2021
1 parent 30b3164 commit f74977a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.2] - 2021-05-04

Try to get documentation to build on docs.rs.


## [0.1.1] - 2021-05-04

Try to get documentation to build on docs.rs.
Expand All @@ -16,6 +21,7 @@ Try to get documentation to build on docs.rs.
Initial release.


[Unreleased]: https://github.com/jgosmann/bsec/compare/v0.1.1...HEAD
[Unreleased]: https://github.com/jgosmann/bsec/compare/v0.1.2...HEAD
[0.1.2]: https://github.com/jgosmann/bsec/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/jgosmann/bsec/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/jgosmann/bsec/releases/tag/v0.1.0
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bsec"
version = "0.1.1"
version = "0.1.2"
authors = ["Jan Gosmann <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
6 changes: 5 additions & 1 deletion src/bme.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//! Interface to BME sensors to read physical measurements.
use super::Input;
#[cfg(not(feature = "docs.rs"))]
#[cfg(not(feature = "docs-rs"))]
use libalgobsec_sys::bsec_bme_settings_t;
use std::{fmt::Debug, time::Duration};

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_bme_settings_t {}

/// Trait to implement for your specific hardware to obtain measurements from
/// the BME sensor.
///
Expand Down
12 changes: 11 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
//! Error types.
use libalgobsec_sys::*;
#[cfg(not(feature = "docs-rs"))]
use libalgobsec_sys::{bsec_library_return_t, bsec_virtual_sensor_t};
use std::fmt::{self, Debug, Display, Formatter};

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_virtual_sensor_t {}

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_library_return_t {}

/// Errors that can occur in the *bsec* crate.
///
/// `E` is the error type of the [`crate::bme::BmeSensor`] is use.
Expand Down Expand Up @@ -143,6 +152,7 @@ impl std::error::Error for BsecError {}
impl From<bsec_library_return_t> for BsecError {
fn from(return_code: bsec_library_return_t) -> Self {
#![allow(non_upper_case_globals)]
use libalgobsec_sys::*;
use BsecError::*;
match return_code {
bsec_library_return_t_BSEC_E_DOSTEPS_INVALIDINPUT => DoStepsInvalidInput,
Expand Down
38 changes: 35 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,15 @@
use crate::bme::{BmeSensor, BmeSettingsHandle};
use crate::clock::Clock;
use crate::error::{BsecError, ConversionError, Error};
#[cfg(not(feature = "docs.rs"))]
use libalgobsec_sys::*;
#[cfg(not(feature = "docs-rs"))]
use libalgobsec_sys::{
bsec_bme_settings_t, bsec_do_steps, bsec_get_configuration, bsec_get_state, bsec_get_version,
bsec_init, bsec_input_t, bsec_library_return_t, bsec_output_t, bsec_physical_sensor_t,
bsec_reset_output, bsec_sensor_configuration_t, bsec_sensor_control, bsec_set_configuration,
bsec_set_state, bsec_update_subscription, bsec_version_t, bsec_virtual_sensor_t,
BSEC_MAX_PHYSICAL_SENSOR, BSEC_MAX_PROPERTY_BLOB_SIZE, BSEC_MAX_STATE_BLOB_SIZE,
BSEC_MAX_WORKBUFFER_SIZE,
};
use std::borrow::Borrow;
use std::convert::{From, TryFrom, TryInto};
use std::fmt::Debug;
Expand All @@ -178,6 +185,26 @@ use std::marker::PhantomData;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_library_return_t {}

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_output_t {}

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_physical_sensor_t {}

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_sensor_configuration_t {}

#[cfg(feature = "docs-rs")]
#[allow(non_camel_case_types)]
struct bsec_virtual_sensor_t {}

pub mod bme;
pub mod clock;
pub mod error;
Expand Down Expand Up @@ -601,6 +628,7 @@ impl From<SampleRate> for f32 {

impl From<SampleRate> for f64 {
fn from(sample_rate: SampleRate) -> Self {
use libalgobsec_sys::*;
use SampleRate::*;
match sample_rate {
Disabled => BSEC_SAMPLE_RATE_DISABLED,
Expand Down Expand Up @@ -640,6 +668,7 @@ impl From<u8> for InputKind {
impl From<u32> for InputKind {
fn from(physical_sensor: u32) -> Self {
#![allow(non_upper_case_globals)]
use libalgobsec_sys::*;
use InputKind::*;
match physical_sensor {
bsec_physical_sensor_t_BSEC_INPUT_PRESSURE => Pressure,
Expand All @@ -655,6 +684,7 @@ impl From<u32> for InputKind {

impl From<InputKind> for bsec_physical_sensor_t {
fn from(physical_sensor: InputKind) -> Self {
use libalgobsec_sys::*;
use InputKind::*;
match physical_sensor {
Pressure => bsec_physical_sensor_t_BSEC_INPUT_PRESSURE,
Expand Down Expand Up @@ -697,6 +727,7 @@ pub enum OutputKind {

impl From<OutputKind> for bsec_virtual_sensor_t {
fn from(virtual_sensor: OutputKind) -> Self {
use libalgobsec_sys::*;
use OutputKind::*;
match virtual_sensor {
Iaq => bsec_virtual_sensor_t_BSEC_OUTPUT_IAQ,
Expand Down Expand Up @@ -725,6 +756,7 @@ impl TryFrom<bsec_virtual_sensor_t> for OutputKind {
type Error = ConversionError;
fn try_from(virtual_sensor: bsec_virtual_sensor_t) -> Result<Self, ConversionError> {
#![allow(non_upper_case_globals)]
use libalgobsec_sys::*;
use OutputKind::*;
match virtual_sensor {
bsec_virtual_sensor_t_BSEC_OUTPUT_IAQ => Ok(Iaq),
Expand Down Expand Up @@ -765,7 +797,7 @@ impl IntoResult for bsec_library_return_t {
fn into_result(self) -> Result<(), BsecError> {
#![allow(non_upper_case_globals)]
match self {
bsec_library_return_t_BSEC_OK => Ok(()),
libalgobsec_sys::bsec_library_return_t_BSEC_OK => Ok(()),
error_code => Err(BsecError::from(error_code)),
}
}
Expand Down

0 comments on commit f74977a

Please sign in to comment.