Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding workflow again. #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
run: |
sudo apt install -y bluez libbluetooth-dev dbus libdbus-1-dev
sudo sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service
sudo systemctl daemon-reload
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apple-ble"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
description = "A library for interfacing with apple devices via BLE."
license = "MIT AND Apache-2.0"
Expand All @@ -15,7 +15,7 @@ bluer = { version = "0.15.3", features = [
] }
config = "0.13.2"
tokio = { version = "1.22.0", features = ["full"] }
async-trait = { version = "0.1.58", optional = true }
async-trait = "0.1.58"
sha2 = "0.10.6"
uuid = { version = "1.2.2", features = ["v4"] }
sudo = "0.6.0"
Expand All @@ -27,7 +27,7 @@ clap = { version = "4.0.29", optional = true }
[features]
default = []
# AFIT = async_fn_in_trait
disable_afit = ["dep:async-trait"]
enable_afit = []
cli = ["dep:clap"]

[[bin]]
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM rust:1.66

RUN apt-get update
RUN apt-get install -y bluez libbluetooth-dev dbus libdbus-1-dev
RUN sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service

COPY . .
6 changes: 3 additions & 3 deletions src/advertisement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Debug;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::{collections::BTreeMap, error::Error, time::Duration};

#[cfg(feature = "disable_afit")]
#[cfg(not(feature = "disable_afit"))]
use async_trait::async_trait;
use bluer::adv::{Advertisement, AdvertisementHandle, Type};
use bluer::{Device, Address};
Expand All @@ -13,12 +13,12 @@ use crate::util::set_device_addr;

const APPLE_MAGIC: u16 = 0x4c;

pub trait AdvertisableData: Clone + PartialEq + Debug {
pub trait AdvertisableData: Clone + PartialEq + Debug + Sync {
fn octets(&self) -> Vec<u8>;
}

// If the user opted out of using "async_fn_in_trait", use the crate async-trait instead.
#[cfg_attr(feature = "disable_afit", async_trait)]
#[cfg_attr(not(feature = "disable_afit"), async_trait)]
/// Any kind of advertisement.
pub trait Advertisable<T: AdvertisableData> {
/// Advertisement-specific: validate user supplied data.
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(incomplete_features)]
// opt-out of using the unstable feature "async_fn_in_trait". See https://github.com/rust-lang/rust/issues/91611.
#![cfg_attr(not(feature = "disable_afit"), feature(async_fn_in_trait))]
#![cfg_attr(feature = "enable_afit", feature(async_fn_in_trait))]
mod util;
pub mod advertisement;
pub mod session;
pub mod session;
pub use bluer;