Returns the bool interpretation of a Toggle feature's cached value. Panics if the value is not exactly 0.0 or 1.0 as a sanity check; a non-boolean value for a toggle means the protocol assumptions are broken and no functionality can be guaranteed.
(&self)
| 453 | /// a non-boolean value for a toggle means the protocol |
| 454 | /// assumptions are broken and no functionality can be guaranteed. |
| 455 | pub fn as_bool(&self) -> bool { |
| 456 | let value = self.value(); |
| 457 | if value == 0.0 { |
| 458 | false |
| 459 | } else if value == 1.0 { |
| 460 | true |
| 461 | } else { |
| 462 | panic!( |
| 463 | "Toggle feature '{}' has invalid value {} (expected 0.0 or 1.0)", |
| 464 | self.id.display_name(), |
| 465 | value |
| 466 | ); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | /// Queries hardware for the current value, updates the cache, returns the fresh value. |
| 471 | pub fn read_from_device(&self) -> f32 { |
no test coverage detected