pub struct MtkUsbManager {
metadata: DeviceMetadata,
udc: String,
}Expand description
USB mass storage manager for MTK platforms.
This implementation configures the USB gadget via ConfigFS, which is the modern approach for MTK-based Kobo devices. It creates the gadget configuration, sets up the mass storage function, and binds to the UDC.
Fields§
§metadata: DeviceMetadata§udc: StringImplementations§
Source§impl MtkUsbManager
impl MtkUsbManager
Sourcepub fn new(metadata: DeviceMetadata) -> Result<Self, UsbError>
pub fn new(metadata: DeviceMetadata) -> Result<Self, UsbError>
Creates a new MTK USB manager.
Discovers the UDC and prepares for gadget setup. No USB operations
are performed until enable is called.
§Errors
Returns UsbError::Udc if no UDC is available or the UDC
directory cannot be read.
Sourcefn create_gadget_dirs(&self) -> Result<(), UsbError>
fn create_gadget_dirs(&self) -> Result<(), UsbError>
Creates the ConfigFS gadget directory structure.
Sourcefn write_gadget_config(&self) -> Result<(), UsbError>
fn write_gadget_config(&self) -> Result<(), UsbError>
Writes gadget configuration to ConfigFS.
All values are written with a trailing \n to match echo behaviour from
the kernel documentation examples.
Sourcefn activate_function(&self) -> Result<(), UsbError>
fn activate_function(&self) -> Result<(), UsbError>
Creates symlinks to activate the mass storage function.
Sourcefn bind_udc(&self) -> Result<(), UsbError>
fn bind_udc(&self) -> Result<(), UsbError>
Binds the gadget to the UDC to enable USB.
The UDC name is written with a trailing \n to match echo behaviour from
the kernel documentation examples.
Sourcefn unbind_udc(&self) -> Result<(), UsbError>
fn unbind_udc(&self) -> Result<(), UsbError>
Unbinds the gadget from the UDC.
Writes a bare newline to the UDC attribute, which the kernel interprets as clearing the binding.
Sourcefn deactivate_function(&self) -> Result<(), UsbError>
fn deactivate_function(&self) -> Result<(), UsbError>
Removes the function symlink.
Sourcefn remove_gadget_dirs(&self) -> Result<(), UsbError>
fn remove_gadget_dirs(&self) -> Result<(), UsbError>
Removes the gadget directory structure.
Trait Implementations§
Source§impl KoboUsbOperations for MtkUsbManager
impl KoboUsbOperations for MtkUsbManager
Source§fn metadata(&self) -> &DeviceMetadata
fn metadata(&self) -> &DeviceMetadata
Source§fn sync_and_drop_caches(&self) -> Result<(), UsbError>
fn sync_and_drop_caches(&self) -> Result<(), UsbError>
Source§fn is_mounted(&self, mount_point: &str) -> Result<bool, UsbError>
fn is_mounted(&self, mount_point: &str) -> Result<bool, UsbError>
Source§fn unmount_partition(&self, mount_point: &str) -> Result<(), UsbError>
fn unmount_partition(&self, mount_point: &str) -> Result<(), UsbError>
Auto Trait Implementations§
impl Freeze for MtkUsbManager
impl RefUnwindSafe for MtkUsbManager
impl Send for MtkUsbManager
impl Sync for MtkUsbManager
impl Unpin for MtkUsbManager
impl UnsafeUnpin for MtkUsbManager
impl UnwindSafe for MtkUsbManager
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