Skip to content

Commit b7c3add

Browse files
committed
uinput: improve ff_upload docs a bit
1 parent e9dbb8e commit b7c3add

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/uinput.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,22 +755,34 @@ impl UinputDevice {
755755
block_until_readable(self.as_raw_fd())
756756
}
757757

758-
/// Performs a requested force-feedback effect upload.
758+
/// Performs a requested force-feedback effect upload or update.
759759
///
760760
/// This should be called when receiving a [`UinputEvent`] with a code of
761761
/// [`UinputCode::FF_UPLOAD`].
762762
///
763+
/// # Error Conversion
764+
///
763765
/// If `handler` returns an error, that error will both be returned to the caller of `ff_upload`
764766
/// and also to whichever process attempted to upload the effect.
765-
/// This requires a lossy conversion to a C style `Exyz` error constant.
766-
/// If `handler` returns a native OS error (eg. via [`io::Error::last_os_error`]), we'll return
767-
/// that error code directly.
768-
/// Otherwise, we'll try to translate the [`io::ErrorKind`] of the error to something sensible.
767+
/// This requires a conversion to a C style `E*` error constant.
768+
///
769+
/// If `handler` returns a native OS error (eg. via [`io::Error::last_os_error`] or
770+
/// [`io::Error::from_raw_os_error`]), that error code will be returned directly, without
771+
/// modification.
772+
///
773+
/// Otherwise, the [`io::ErrorKind`] of the error is converted to something sensible, falling
774+
/// back to returning the generic `EIO` error when there is no suitable error code.
775+
/// The precise mapping used for this conversion should not be relied on, and may change as
776+
/// Rust adds new [`io::ErrorKind`] values.
769777
///
770778
/// # Platform-specific behavior
771779
///
772780
/// This functionality is stubbed out on FreeBSD. [`UinputEvent`]s are never sent to the
773781
/// [`UinputDevice`].
782+
///
783+
/// # Panics
784+
///
785+
/// This method will panic if the given [`UinputEvent`] is not a force-feedback upload event.
774786
#[doc(alias = "UI_BEGIN_FF_UPLOAD", alias = "UI_END_FF_UPLOAD")]
775787
pub fn ff_upload<R>(
776788
&self,
@@ -822,6 +834,10 @@ impl UinputDevice {
822834
///
823835
/// This functionality is stubbed out on FreeBSD. [`UinputEvent`]s are never sent to the
824836
/// [`UinputDevice`].
837+
///
838+
/// # Panics
839+
///
840+
/// This method will panic if the given [`UinputEvent`] is not a force-feedback erase event.
825841
#[doc(alias = "UI_BEGIN_FF_ERASE", alias = "UI_END_FF_ERASE")]
826842
pub fn ff_erase(
827843
&self,

0 commit comments

Comments
 (0)