Skip to content

Commit

Permalink
Replacing looks-to-be-abandoned dependencies for MacOS targets (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Feb 28, 2019
1 parent 8ad3106 commit 97868db
Show file tree
Hide file tree
Showing 17 changed files with 546 additions and 328 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Version](https://img.shields.io/crates/v/battery.svg)](https://crates.io/crates/battery)
[![Latest Version](https://docs.rs/battery/badge.svg)](https://docs.rs/battery)
[![Build Status](https://travis-ci.org/svartalf/rust-battery.svg?branch=master)](https://travis-ci.org/svartalf/rust-battery)
[![dependency status](https://deps.rs/crate/battery/0.6.1/status.svg)](https://deps.rs/crate/battery/0.6.1)
[![dependency status](https://deps.rs/crate/battery/0.6.2/status.svg)](https://deps.rs/crate/battery/0.6.2)
![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg)

Rust crate providing cross-platform information about batteries.
Expand All @@ -14,7 +14,7 @@ recalculated as necessary to be returned in `mW`, `mWh` or `mV` units.
## Supported platforms

* Linux 2.6.39+
* MacOS (10.10+ probably, needs to be confirmed)
* MacOS 10.10+
* Windows 7+
* FreeBSD
* DragonFlyBSD
Expand All @@ -23,11 +23,13 @@ recalculated as necessary to be returned in `mW`, `mWh` or `mV` units.

Until `1.0.0` version API might change in any moment, be careful.

## Example
## Examples

See `battery-cli` crate at [GitHub](https://github.com/svartalf/rust-battery/tree/master/battery-cli/)
See full-featured `battery-cli` crate at [GitHub](https://github.com/svartalf/rust-battery/tree/master/battery-cli/)
or at [crates.io](https://crates.rs/crate/battery-cli).

For a simple example check `battery/examples/simple.rs` in the [repository](https://github.com/svartalf/rust-battery/blob/master/battery/examples/simple.rs)

## FFI

Experimental [battery-ffi](https://crates.io/crates/battery-ffi) crate
Expand Down
4 changes: 2 additions & 2 deletions battery-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "battery-cli"
version = "0.1.2"
version = "0.1.3"
authors = ["svartalf <self@svartalf.info>"]
edition = "2018"
description = "CLI tool for batteries reports"
Expand All @@ -25,7 +25,7 @@ test = false
cfg-if = "0.1"

[target.'cfg(not(windows))'.dependencies]
battery = "0.6.1"
battery = "0.6.2"
humantime = "1.2.0"
tui = "0.4.0"
termion = "1.5.1"
Expand Down
2 changes: 1 addition & 1 deletion battery-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Version](https://img.shields.io/crates/v/battery-cli.svg)](https://crates.io/crates/battery-cli)
[![Latest Version](https://docs.rs/battery-cli/badge.svg)](https://docs.rs/battery-cli)
[![Build Status](https://travis-ci.org/svartalf/rust-battery.svg?branch=master)](https://travis-ci.org/svartalf/rust-battery)
[![dependency status](https://deps.rs/crate/battery-cli/0.1.2/status.svg)](https://deps.rs/crate/battery-cli/0.1.2)
[![dependency status](https://deps.rs/crate/battery-cli/0.1.3/status.svg)](https://deps.rs/crate/battery-cli/0.1.3)
![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg)

`battery-cli` is a Proof-Of-Concept binary crate, that provides terminal user interface
Expand Down
4 changes: 2 additions & 2 deletions battery-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "battery-ffi"
version = "0.1.4"
version = "0.1.5"
authors = ["svartalf <self@svartalf.info>"]
edition = "2018"
description = "FFI bindings for battery crate"
Expand All @@ -22,7 +22,7 @@ crate-type = ["cdylib"]
default = ["cbindgen"]

[dependencies]
battery = "0.6.1"
battery = "0.6.2"
libc = "0.2.48"

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion battery-ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Version](https://img.shields.io/crates/v/battery-ffi.svg)](https://crates.io/crates/battery-ffi)
[![Latest Version](https://docs.rs/battery-ffi/badge.svg)](https://docs.rs/battery-ffi)
[![Build Status](https://travis-ci.org/svartalf/rust-battery.svg?branch=master)](https://travis-ci.org/svartalf/rust-battery)
[![dependency status](https://deps.rs/crate/battery-ffi/0.1.4/status.svg)](https://deps.rs/crate/battery-ffi/0.1.4)
[![dependency status](https://deps.rs/crate/battery-ffi/0.1.5/status.svg)](https://deps.rs/crate/battery-ffi/0.1.5)
![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg)

This is a FFI bindings for [battery](https://github.com/svartalf/rust-battery/tree/master/battery)
Expand Down
6 changes: 6 additions & 0 deletions battery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.2] - 2019-02-28
### Changed
- Replace looks-to-be-abandoned `CoreFoundation-sys` and `IOKit-sys` dependencies [#2](https://github.com/svartalf/rust-battery/issues/2)
### Fixed
- Free hanging mach port used for communication with Mac OS IOKit

## [0.6.1] - 2019-02-27
### Fixed
- Fix energy and remaining time calculations for MacOS [#8](https://github.com/svartalf/rust-battery/issues/8), [#11](https://github.com/svartalf/rust-battery/pull/11)
Expand Down
7 changes: 3 additions & 4 deletions battery/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "battery"
version = "0.6.1"
version = "0.6.2"
authors = ["svartalf <self@svartalf.info>"]
edition = "2018"
description = "Cross-platform information about batteries"
Expand All @@ -21,10 +21,9 @@ cfg-if = "0.1"
lazy-init = "0.3"

[target.'cfg(target_os = "macos")'.dependencies]
CoreFoundation-sys = "0.1.4"
IOKit-sys = "0.1.5"
mach = "0.1.2"
libc = "0.2.48"
mach = "0.1.2"
core-foundation = "0.6.3"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version ="0.3.6", features = ["impl-default", "devguid", "winbase", "ioapiset", "ntdef", "setupapi", "handleapi", "errhandlingapi", "winerror"] }
Expand Down
9 changes: 3 additions & 6 deletions battery/src/platform/macos/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// - ChargingCurrent
// - NotChargingReason (?)

use std::io;
use std::str;
use std::boxed::Box;
use std::convert::AsRef;
Expand All @@ -17,18 +16,16 @@ use super::traits::DataSource;

#[derive(Debug)]
pub struct IoKitDevice {
source: Box<DataSource>,
source: Box<dyn DataSource>,

manufacturer: Option<String>,
model: Option<String>,
serial_number: Option<String>,
}

impl IoKitDevice {
pub fn new<T: DataSource>() -> io::Result<IoKitDevice> {
let ds = T::new()?;

Ok(ds.into())
pub fn get_mut_ref(&mut self) -> &mut dyn DataSource {
&mut self.source
}
}

Expand Down
Loading

0 comments on commit 97868db

Please sign in to comment.