Merge pull request #450 from ia0/add_doc
Add documentation for #[cfg] work-around on expressions
This commit is contained in:
@@ -542,6 +542,8 @@ impl CtapState {
|
|||||||
// Correct behavior between CTAP1 and CTAP2 isn't defined yet. Just a guess.
|
// Correct behavior between CTAP1 and CTAP2 isn't defined yet. Just a guess.
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
{
|
{
|
||||||
|
// We create a block statement to wrap this assignment expression, because attributes
|
||||||
|
// (like #[cfg]) are not supported on expressions.
|
||||||
self.u2f_up_state = U2fUserPresenceState::new(U2F_UP_PROMPT_TIMEOUT, TOUCH_TIMEOUT);
|
self.u2f_up_state = U2fUserPresenceState::new(U2F_UP_PROMPT_TIMEOUT, TOUCH_TIMEOUT);
|
||||||
}
|
}
|
||||||
self.stateful_command_permission
|
self.stateful_command_permission
|
||||||
@@ -1173,10 +1175,8 @@ impl CtapState {
|
|||||||
String::from(FIDO2_1_VERSION_STRING),
|
String::from(FIDO2_1_VERSION_STRING),
|
||||||
];
|
];
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
{
|
if !has_always_uv {
|
||||||
if !has_always_uv {
|
versions.insert(0, String::from(U2F_VERSION_STRING))
|
||||||
versions.insert(0, String::from(U2F_VERSION_STRING))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let mut options = vec![];
|
let mut options = vec![];
|
||||||
if ENTERPRISE_ATTESTATION_MODE.is_some() {
|
if ENTERPRISE_ATTESTATION_MODE.is_some() {
|
||||||
@@ -1246,6 +1246,8 @@ impl CtapState {
|
|||||||
self.client_pin.reset(env.rng());
|
self.client_pin.reset(env.rng());
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
{
|
{
|
||||||
|
// We create a block statement to wrap this assignment expression, because attributes
|
||||||
|
// (like #[cfg]) are not supported on expressions.
|
||||||
self.u2f_up_state = U2fUserPresenceState::new(U2F_UP_PROMPT_TIMEOUT, TOUCH_TIMEOUT);
|
self.u2f_up_state = U2fUserPresenceState::new(U2F_UP_PROMPT_TIMEOUT, TOUCH_TIMEOUT);
|
||||||
}
|
}
|
||||||
Ok(ResponseData::AuthenticatorReset)
|
Ok(ResponseData::AuthenticatorReset)
|
||||||
|
|||||||
16
src/main.rs
16
src/main.rs
@@ -82,8 +82,8 @@ fn main() {
|
|||||||
});
|
});
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
let mut buttons = buttons_callback.init().flex_unwrap();
|
let mut buttons = buttons_callback.init().flex_unwrap();
|
||||||
#[cfg(feature = "with_ctap1")]
|
|
||||||
// At the moment, all buttons are accepted. You can customize your setup here.
|
// At the moment, all buttons are accepted. You can customize your setup here.
|
||||||
|
#[cfg(feature = "with_ctap1")]
|
||||||
for mut button in &mut buttons {
|
for mut button in &mut buttons {
|
||||||
button.enable().flex_unwrap();
|
button.enable().flex_unwrap();
|
||||||
}
|
}
|
||||||
@@ -168,14 +168,12 @@ fn main() {
|
|||||||
#[cfg(not(feature = "with_ctap1"))]
|
#[cfg(not(feature = "with_ctap1"))]
|
||||||
switch_off_leds();
|
switch_off_leds();
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
{
|
if ctap.state().u2f_needs_user_presence(now) {
|
||||||
if ctap.state().u2f_needs_user_presence(now) {
|
// Flash the LEDs with an almost regular pattern. The inaccuracy comes from
|
||||||
// Flash the LEDs with an almost regular pattern. The inaccuracy comes from
|
// delay caused by processing and sending of packets.
|
||||||
// delay caused by processing and sending of packets.
|
blink_leds(led_counter);
|
||||||
blink_leds(led_counter);
|
} else {
|
||||||
} else {
|
switch_off_leds();
|
||||||
switch_off_leds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
third_party/libtock-drivers/src/usb_ctap_hid.rs
vendored
12
third_party/libtock-drivers/src/usb_ctap_hid.rs
vendored
@@ -188,10 +188,8 @@ pub fn recv_with_timeout(
|
|||||||
let result = recv_with_timeout_detail(buf, timeout_delay);
|
let result = recv_with_timeout_detail(buf, timeout_delay);
|
||||||
|
|
||||||
#[cfg(feature = "verbose_usb")]
|
#[cfg(feature = "verbose_usb")]
|
||||||
{
|
if let Some(SendOrRecvStatus::Received) = result {
|
||||||
if let Some(SendOrRecvStatus::Received) = result {
|
writeln!(Console::new(), "Received packet = {:02x?}", buf as &[u8]).unwrap();
|
||||||
writeln!(Console::new(), "Received packet = {:02x?}", buf as &[u8]).unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
@@ -216,10 +214,8 @@ pub fn send_or_recv_with_timeout(
|
|||||||
let result = send_or_recv_with_timeout_detail(buf, timeout_delay);
|
let result = send_or_recv_with_timeout_detail(buf, timeout_delay);
|
||||||
|
|
||||||
#[cfg(feature = "verbose_usb")]
|
#[cfg(feature = "verbose_usb")]
|
||||||
{
|
if let Some(SendOrRecvStatus::Received) = result {
|
||||||
if let Some(SendOrRecvStatus::Received) = result {
|
writeln!(Console::new(), "Received packet = {:02x?}", buf as &[u8]).unwrap();
|
||||||
writeln!(Console::new(), "Received packet = {:02x?}", buf as &[u8]).unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|||||||
Reference in New Issue
Block a user