pub struct CURRENT_DEVICE {
__private_field: (),
}Expand description
Global singleton for the current device.
Fields§
§__private_field: ()Methods from Deref<Target = Device>§
Sourcepub fn metadata(&self) -> Result<&DeviceMetadata, DeviceError>
pub fn metadata(&self) -> Result<&DeviceMetadata, DeviceError>
Gets device metadata (lazy initialization).
Sourcepub fn usb_manager(&self) -> Result<Box<dyn UsbManager>, UsbError>
pub fn usb_manager(&self) -> Result<Box<dyn UsbManager>, UsbError>
Creates USB manager for this device.
Sourcepub fn wifi_manager(&self) -> Result<&dyn WifiManager, WifiError>
pub fn wifi_manager(&self) -> Result<&dyn WifiManager, WifiError>
Returns the WiFi manager for this device.
Sourcepub fn install_subdir(&self) -> &'static str
pub fn install_subdir(&self) -> &'static str
Returns the install subdirectory for this build.
Kobo devices install Cadmus under .adds/ on the user-visible storage.
Test builds use a separate sibling directory so they can coexist with
stable builds.
Sourcepub fn install_dir(&self) -> PathBuf
pub fn install_dir(&self) -> PathBuf
Returns the absolute install directory for this device.
The path is determined at compile time and does not depend on the
process’s current working directory, so it remains stable even when
callers change cwd.
- Normal device builds:
/mnt/onboard/.adds/cadmus - Test device builds:
/mnt/onboard/.adds/cadmus-tst - Emulator builds:
/tmp/.adds/cadmus(orcadmus-tstwithtest) - Unit tests:
<temp_dir>/test-kobo-installation/.adds/cadmus-tst
Sourcepub fn install_path(&self, relative_path: impl AsRef<Path>) -> PathBuf
pub fn install_path(&self, relative_path: impl AsRef<Path>) -> PathBuf
Returns a path inside the device install directory.
Use this for files and directories that Cadmus owns under its install
root, such as tmp/ or .github_token.
Sourcepub fn tmp_dir(&self) -> PathBuf
pub fn tmp_dir(&self) -> PathBuf
Returns the path to the device-managed tmp directory.
The returned path is rooted under Device::install_dir, so it remains
stable even when callers change cwd (for example during USB sharing).
Sourcepub fn clean_tmp_dir(&self)
pub fn clean_tmp_dir(&self)
Removes stale contents left by a previous run and recreates the tmp directory.
Device owns the lifecycle of the tmp directory: callers may assume
the directory exists after this runs and should not create it
themselves. Call this once at startup before any feature that writes
to tmp_dir() to ensure a clean slate.
Sourcepub fn color_samples(&self) -> usize
pub fn color_samples(&self) -> usize
Returns the number of color samples for the device screen.
Sourcepub fn frontlight_kind(&self) -> FrontlightKind
pub fn frontlight_kind(&self) -> FrontlightKind
Returns the frontlight kind for this device.
Sourcepub fn has_natural_light(&self) -> bool
pub fn has_natural_light(&self) -> bool
Returns true if the device has natural light capability.
Sourcepub fn has_lightsensor(&self) -> bool
pub fn has_lightsensor(&self) -> bool
Returns true if the device has a light sensor.
Sourcepub fn has_gyroscope(&self) -> bool
pub fn has_gyroscope(&self) -> bool
Returns true if the device has a gyroscope.
Returns true if the device has page turn buttons.
Sourcepub fn has_power_cover(&self) -> bool
pub fn has_power_cover(&self) -> bool
Returns true if the device supports a power cover.
Sourcepub fn has_removable_storage(&self) -> bool
pub fn has_removable_storage(&self) -> bool
Returns true if the device has removable storage.
Returns true if buttons should be inverted for the given rotation.
Sourcepub fn orientation(&self, rotation: i8) -> Orientation
pub fn orientation(&self, rotation: i8) -> Orientation
Returns the orientation for the given rotation.
Sourcepub fn should_mirror_axes(&self, rotation: i8) -> (bool, bool)
pub fn should_mirror_axes(&self, rotation: i8) -> (bool, bool)
Returns whether axes should be mirrored for the given rotation.
Sourcepub fn mirroring_scheme(&self) -> (i8, i8)
pub fn mirroring_scheme(&self) -> (i8, i8)
Returns the center and direction of the mirroring pattern.
Sourcepub fn should_swap_axes(&self, rotation: i8) -> bool
pub fn should_swap_axes(&self, rotation: i8) -> bool
Returns true if axes should be swapped for the given rotation.
Sourcefn swapping_scheme(&self) -> i8
fn swapping_scheme(&self) -> i8
Returns the swapping scheme value.
Sourcepub fn startup_rotation(&self) -> i8
pub fn startup_rotation(&self) -> i8
Returns the startup rotation value.
Sourcepub fn to_canonical(&self, n: i8) -> i8
pub fn to_canonical(&self, n: i8) -> i8
Returns a device independent rotation value.
Sourcepub fn from_canonical(&self, n: i8) -> i8
pub fn from_canonical(&self, n: i8) -> i8
Returns a device dependent rotation value from canonical.
Sourcepub fn transformed_rotation(&self, n: i8) -> i8
pub fn transformed_rotation(&self, n: i8) -> i8
Returns the transformed rotation value.
Sourcepub fn transformed_gyroscope_rotation(&self, n: i8) -> i8
pub fn transformed_gyroscope_rotation(&self, n: i8) -> i8
Returns the transformed gyroscope rotation value.
Trait Implementations§
Source§impl Deref for CURRENT_DEVICE
impl Deref for CURRENT_DEVICE
impl LazyStatic for CURRENT_DEVICE
Auto Trait Implementations§
impl Freeze for CURRENT_DEVICE
impl RefUnwindSafe for CURRENT_DEVICE
impl Send for CURRENT_DEVICE
impl Sync for CURRENT_DEVICE
impl Unpin for CURRENT_DEVICE
impl UnsafeUnpin for CURRENT_DEVICE
impl UnwindSafe for CURRENT_DEVICE
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more