Skip to content

Commit

Permalink
Add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Jan 6, 2025
1 parent dcff900 commit 6edcb14
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: ci

on: [pull_request, push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install Rust toolchain
run: rustup show active-toolchain || rustup toolchain install
- name: check
run: |
cargo check --workspace --all-features --all-targets
- name: test
run: |
cargo test --all-features --workspace
- name: lint
run: |
cargo fmt --check --all
cargo clippy --workspace --all-features --all-targets -- -Dwarnings
RUSTDOCFLAGS='-Dwarnings' cargo doc --workspace --all-features --no-deps
4 changes: 2 additions & 2 deletions src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct CtapHid<'alloc, 'pipe, 'interrupt, Bus: UsbBus> {
pipe: Pipe<'alloc, 'pipe, 'interrupt, Bus>,
}

impl<'alloc, 'pipe, 'interrupt, Bus> CtapHid<'alloc, 'pipe, 'interrupt, Bus>
impl<'alloc, 'pipe, Bus> CtapHid<'alloc, 'pipe, '_, Bus>
where
Bus: UsbBus,
{
Expand Down Expand Up @@ -218,7 +218,7 @@ pub enum ClassRequests {
SetProtocol = 0xB,
}

impl<'alloc, 'pipe, 'interrupt, Bus> UsbClass<Bus> for CtapHid<'alloc, 'pipe, 'interrupt, Bus>
impl<Bus> UsbClass<Bus> for CtapHid<'_, '_, '_, Bus>
where
Bus: UsbBus,
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
usbd-ctaphid
See "proposed standard":
https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#usb
<https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#usb>
*/

Expand Down
15 changes: 7 additions & 8 deletions src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Pipe<'alloc, 'pipe, 'interrupt, Bus: UsbBus> {
pub(crate) version: crate::Version,
}

impl<'alloc, 'pipe, 'interrupt, Bus: UsbBus> Pipe<'alloc, 'pipe, 'interrupt, Bus> {
impl<'alloc, 'pipe, Bus: UsbBus> Pipe<'alloc, 'pipe, '_, Bus> {
pub(crate) fn new(
read_endpoint: EndpointOut<'alloc, Bus>,
write_endpoint: EndpointIn<'alloc, Bus>,
Expand Down Expand Up @@ -316,7 +316,10 @@ impl<'alloc, 'pipe, 'interrupt, Bus: UsbBus> Pipe<'alloc, 'pipe, 'interrupt, Bus
// `solo ls` crashes here as it uses command 0x86
Err(_) => {
info!("Received invalid command.");
self.start_sending_error_on_channel(channel, AuthenticatorError::InvalidCommand);
self.start_sending_error_on_channel(
channel,
AuthenticatorError::InvalidCommand,
);
return;
}
};
Expand Down Expand Up @@ -526,11 +529,7 @@ impl<'alloc, 'pipe, 'interrupt, Bus: UsbBus> Pipe<'alloc, 'pipe, 'interrupt, Bus
}

_ => {
if request.command == Command::Cbor {
self.needs_keepalive = true;
} else {
self.needs_keepalive = false;
}
self.needs_keepalive = request.command == Command::Cbor;
if self.interchange.state() == interchange::State::Responded {
info!("dumping stale response");
self.interchange.take_response();
Expand Down Expand Up @@ -625,7 +624,7 @@ impl<'alloc, 'pipe, 'interrupt, Bus: UsbBus> Pipe<'alloc, 'pipe, 'interrupt, Bus
message.len()
);
let response = Response::from_request_and_size(request, message.len());
self.buffer[..message.len()].copy_from_slice(&message);
self.buffer[..message.len()].copy_from_slice(message);
self.start_sending(response);
}
}
Expand Down

0 comments on commit 6edcb14

Please sign in to comment.