Device in kernel::serdev - Rust
Skip to main content Device kernel :: serdev Struct Device Source pub struct Device<Ctx: DeviceContext = Normal >( /* private fields */ ); Expand description The serial device bus device representation. This structure represents the Rust abstraction for a C struct serdev_device . The implementation abstracts the usage of an already existing C struct serdev_device within Rust code that we get passed from the C side. § Invariants A Device instance represents a valid struct serdev_device created by the C portion of the kernel.
Implementations § Source § impl Device < Bound > Source pub fn set_baudrate (&self, speed: u32 ) -> Result < () , u32 > Set the baudrate in bits per second. Common baudrates are 115200, 9600, 19200, 57600, 4800. Use Device::write_flush before calling this if you have written data prior to this call. Source pub fn set_flow_control (&self, enable: bool ) Set if flow control should be enabled. Use Device::write_flush before calling this if you have written data prior to this call.
Source pub fn set_parity (&self, parity: Parity ) -> Result Set parity to use. Use Device::write_flush before calling this if you have written data prior to this call. Source pub fn write_all (&self, data: &[ u8 ], timeout: Jiffies ) -> Result < usize > Write data to the serial device until the controller has accepted all the data or has been interrupted by a timeout or signal. Note that any accepted data has only been buffered by the controller.
Use Device::wait_until_sent to make sure the controller write buffer has actually been emptied. Use a timeout of 0 to wait indefinitely. Returns the number of bytes written (less than data.len() if interrupted). kernel::error::code::ETIMEDOUT or kernel::error::code::ERESTARTSYS if interrupted before any bytes were written. kernel::error::code::EINVAL if data.len() > i32::MAX . Source pub fn write (&self, data: &[ u8 ]) -> Result < u32 > Write data to the serial device.
If you want to write until the controller has accepted all the data, use Device::write_all . Note that any accepted data has only been buffered by the controller. Use Device::wait_until_sent to make sure the controller write buffer has actually been emptied. Returns the number of bytes written (less than data.len() if not enough room in the write buffer). Source pub fn write_flush (&self) Send data to the serial device immediately.
Note that this doesn’t guarantee that the data has been transmitted. Use Device::wait_until_sent for this purpose. Source pub fn wait_until_sent (&self, timeout: Jiffies ) Wait for the data to be sent. After this function, the write buffer of the controller should be empty or the timeout elapsed. Use a timeout of 0 to wait indefinitely. Trait Implementations § Source § impl AlwaysRefCounted for Device Source § fn inc_ref (&self) Increments the reference count on the object.
Source § unsafe fn dec_ref (obj: NonNull <Self>) Decrements the reference count on the object. Read more Source § impl<Ctx: DeviceContext > AsBusDevice <Ctx> for Device <Ctx> Source § const OFFSET : usize The relative offset to the device field. Read more Source § unsafe fn from_device (dev: & Device <Ctx>) -> &Self where Self: Sized , Convert a reference to Device into Self . Read more Source § impl<Ctx: DeviceContext > AsRef < Device <Ctx>> for Device <Ctx> Source § fn as_ref (&self) -> & Device <Ctx> Converts this type into a shared reference of the (usually inferred) input type.
Source § impl<'a> Deref for Device < CoreInternal <'a>> Source § type Target = Device < Core <'a>> The resulting type after dereferencing. Source § fn deref (&self) -> &Self:: Target Dereferences the value. Source § impl<'a> Deref for Device < Core <'a>> Source § type Target = Device < Bound > The resulting type after dereferencing. Source § fn deref (&self) -> &Self:: Target Dereferences the value. Source § impl Deref for Device < BoundInternal > Source § type Target = Device < Bound > The resulting type after dereferencing.
Source § fn deref (&self) -> &Self:: Target Dereferences the value. Source § impl Deref for Device < Bound > Source § type Target = Device The resulting type after dereferencing. Source § fn deref (&self) -> &Self:: Target Dereferences the value. Source § impl From <& Device < Bound >> for ARef < Device > Source § fn from (dev: & Device < Bound >) -> Self Converts to this type from the input type. Source § impl From <& Device < BoundInternal >> for ARef < Device > Source § fn from (dev: & Device < BoundInternal >) -> Self Converts to this type from the input type.
Source § impl<'a> From <& Device < Core <'a>>> for ARef < Device > Source § fn from (dev: & Device < Core <'a>>) -> Self Converts to this type from the input type. Source § impl<'a> From <& Device < CoreInternal <'a>>> for ARef < Device > Source § fn from (dev: & Device < CoreInternal <'a>>) -> Self Converts to this type from the input type. Source § impl Send for Device Source § impl Sync for Device Source § impl Sync for Device < Bound > Auto Trait Implementations § § impl<Ctx = Normal > !
Freeze for Device <Ctx> § impl<Ctx = Normal > ! RefUnwindSafe for Device <Ctx> § impl<Ctx = Normal > ! Send for Device <Ctx> § impl<Ctx = Normal > ! Sync for Device <Ctx> § impl<Ctx = Normal > ! Unpin for Device <Ctx> § impl<Ctx = Normal > ! UnsafeUnpin for Device <Ctx> § impl<Ctx> UnwindSafe for Device <Ctx> where Ctx: UnwindSafe , Blanket Implementations § Source § impl<T> Any for T where T: 'static + ? Sized , Source § fn type_id (&self) -> TypeId Gets the TypeId of self .
Read more Source § impl<T> Borrow <T> for T where T: ? Sized , Source § fn borrow (&self) -> &T Immutably borrows from an owned value. Read more Source § impl<T> BorrowMut <T> for T where T: ? Sized , Source § fn borrow_mut (&mut self) -> &mut T Mutably borrows from an owned value. Read more Source § impl<ST, DT> CastableFrom <ST, Initialized , Initialized > for DT where ST: ? Sized , DT: ? Sized , Source § impl<ST, DT> CastableFrom <ST, Uninit , Uninit > for DT where ST: ?
Sized , DT: ? Sized , Source § impl<T> From <T> for T Source § fn from (t: T) -> T Returns the argument unchanged. Source § impl<T> Init <T> for T Source § fn chain <F>(self, f: F) -> ChainInit <Self, F, T, E> where F: FnOnce ( &mut T ) -> Result < () , E>, First initializes the value using self then calls the function f with the initialized value. Read more Source § impl<T, U> Into <U> for T where U: From <T>, Source § fn into (self) -> U Calls U::from(self) .
That is, this conversion is whatever the implementation of From <T> for U chooses to do. Source § impl<S, T> IntoSafeCast <T> for S where T: FromSafeCast <S>, Source § fn into_safe_cast (self) -> T Convert self into a T . This operation is guaranteed to be lossless. Source § impl<S, T> IntoSafeCastArch <T> for S where T: FromSafeCastArch <S>, Source § fn into_safe_cast_arch (self) -> T Convert self into a T . This operation is guaranteed to be lossless.
Source § impl<T> KnownSize for T Source § const MIN_SIZE : usize = const MIN_SIZE: usize = size_of::<T>(); Minimum size of this type known at compile-time. Source § const MIN_ALIGN : Alignment = const MIN_ALIGN: Alignment = Alignment::of::<T>(); Minimum alignment of this type known at compile-time. Source § fn size (_: *const T ) -> usize Get the size of an object of this type in bytes, with the metadata of the given pointer.
Source § impl<T> PinInit <T> for T Source § unsafe fn __init (self, slot: *mut T ) -> Result < () , ! > Initializes slot . Read more Source § fn pin_chain <F>(self, f: F) -> ChainPinInit <Self, F, T, E> where F: FnOnce ( Pin < &mut T >) -> Result < () , E>, First initializes the value using self then calls the function f with the initialized value. Read more Source § impl<T> Read < Exclusive , BecauseExclusive > for T where T: ?
Sized , Source § impl<P, T> Receiver for P where P: Deref <Target = T> + ? Sized , T: ? Sized , Source § type Target = T 🔬 This is a
The rest of this page is on the live site.