From: Kent Gibson <warthog618@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
linux-gpio@vger.kernel.org,
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@google.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
stratos-dev@op-lists.linaro.org,
"Gerard Ryan" <g.m0n3y.2503@gmail.com>
Subject: Re: [PATCH V4 6/8] libgpiod: Derive debug traits for few definitions
Date: Wed, 27 Jul 2022 10:58:32 +0800 [thread overview]
Message-ID: <20220727025832.GF88787@sol> (raw)
In-Reply-To: <490e4efc900d8173fb3e2f1373c97e1a20cb9ac3.1657279685.git.viresh.kumar@linaro.org>
On Fri, Jul 08, 2022 at 05:04:59PM +0530, Viresh Kumar wrote:
> These are required for tests, which will be added by a later commit.
>
Squash this patch into patch 4, as you know you will need them
eventually. All public types should implement Debug[1].
They should also implement Clone, Eq, PartialEq and Default where
that makes sense. And Copy if you are sure you wont add something
non-Copyable to them in the future.
Cheers,
Kent.
[1] https://rust-lang.github.io/api-guidelines/debuggability.html
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> bindings/rust/src/chip.rs | 5 +++++
> bindings/rust/src/chip_info.rs | 1 +
> bindings/rust/src/lib.rs | 8 +++++++-
> bindings/rust/src/line_info.rs | 1 +
> 4 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/bindings/rust/src/chip.rs b/bindings/rust/src/chip.rs
> index 50b5d6102f96..ecff4b003cd9 100644
> --- a/bindings/rust/src/chip.rs
> +++ b/bindings/rust/src/chip.rs
> @@ -21,6 +21,7 @@ use super::{
> /// character device. It exposes basic information about the chip and allows
> /// callers to retrieve information about each line, watch lines for state
> /// changes and make line requests.
> +#[derive(Debug)]
> pub(crate) struct ChipInternal {
> chip: *mut bindings::gpiod_chip,
> }
> @@ -52,11 +53,15 @@ impl Drop for ChipInternal {
> }
> }
>
> +#[derive(Debug)]
> pub struct Chip {
> ichip: Arc<ChipInternal>,
> info: ChipInfo,
> }
>
> +unsafe impl Send for Chip {}
> +unsafe impl Sync for Chip {}
> +
> impl Chip {
> /// Find a chip by path.
> pub fn open(path: &str) -> Result<Self> {
> diff --git a/bindings/rust/src/chip_info.rs b/bindings/rust/src/chip_info.rs
> index 950368b54c6f..7188f91a92a6 100644
> --- a/bindings/rust/src/chip_info.rs
> +++ b/bindings/rust/src/chip_info.rs
> @@ -11,6 +11,7 @@ use vmm_sys_util::errno::Error as IoError;
> use super::{bindings, ChipInternal, Error, Result};
>
> /// GPIO chip Information
> +#[derive(Debug)]
> pub struct ChipInfo {
> info: *mut bindings::gpiod_chip_info,
> }
> diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs
> index 2f2ac515d353..63b0b82281b7 100644
> --- a/bindings/rust/src/lib.rs
> +++ b/bindings/rust/src/lib.rs
> @@ -59,6 +59,7 @@ pub enum Error {
> }
>
> /// Direction settings.
> +#[derive(Debug, PartialEq)]
> pub enum Direction {
> /// Request the line(s), but don't change direction.
> AsIs,
> @@ -88,6 +89,7 @@ impl Direction {
> }
>
> /// Internal bias settings.
> +#[derive(Debug, PartialEq)]
> pub enum Bias {
> /// Don't change the bias setting when applying line config.
> AsIs,
> @@ -125,6 +127,7 @@ impl Bias {
> }
>
> /// Drive settings.
> +#[derive(Debug, PartialEq)]
> pub enum Drive {
> /// Drive setting is push-pull.
> PushPull,
> @@ -154,6 +157,7 @@ impl Drive {
> }
>
> /// Edge detection settings.
> +#[derive(Debug, PartialEq)]
> pub enum Edge {
> /// Line edge detection is disabled.
> None,
> @@ -223,6 +227,7 @@ impl Config {
> }
>
> /// Event clock settings.
> +#[derive(Debug, PartialEq)]
> pub enum EventClock {
> /// Line uses the monotonic clock for edge event timestamps.
> Monotonic,
> @@ -248,6 +253,7 @@ impl EventClock {
> }
>
> /// Line status change event types.
> +#[derive(Debug, PartialEq)]
> pub enum Event {
> /// Line has been requested.
> LineRequested,
> @@ -268,7 +274,7 @@ impl Event {
> }
> }
>
> -#[derive(Copy, Clone)]
> +#[derive(Copy, Clone, Debug, PartialEq)]
> /// Edge event types.
> pub enum LineEdgeEvent {
> /// Rising edge event.
> diff --git a/bindings/rust/src/line_info.rs b/bindings/rust/src/line_info.rs
> index 70b6bd6a84bb..426bd16aa616 100644
> --- a/bindings/rust/src/line_info.rs
> +++ b/bindings/rust/src/line_info.rs
> @@ -23,6 +23,7 @@ use super::{
> /// line, which does not include the line value. The line must be requested
> /// to access the line value.
>
> +#[derive(Debug)]
> pub struct LineInfo {
> info: *mut bindings::gpiod_line_info,
> ichip: Option<Arc<ChipInternal>>,
> --
> 2.31.1.272.g89b43f80a514
>
next prev parent reply other threads:[~2022-07-27 2:58 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 11:34 [PATCH V4 0/8] libgpiod: Add Rust bindings Viresh Kumar
2022-07-08 11:34 ` [PATCH V4 1/8] libgpiod: Add libgpiod-sys rust crate Viresh Kumar
2022-07-27 2:57 ` Kent Gibson
2022-07-27 4:51 ` Viresh Kumar
2022-07-27 5:17 ` Kent Gibson
2022-07-27 5:45 ` Viresh Kumar
2022-08-01 12:11 ` Viresh Kumar
2022-08-01 15:56 ` Kent Gibson
2022-08-02 8:50 ` Viresh Kumar
2022-08-02 9:36 ` Kent Gibson
2022-07-08 11:34 ` [PATCH V4 2/8] libgpiod: Add pre generated rust bindings Viresh Kumar
2022-07-27 2:57 ` Kent Gibson
2022-07-27 5:15 ` Viresh Kumar
2022-07-27 5:31 ` Kent Gibson
2022-07-27 6:00 ` Viresh Kumar
2022-07-27 6:06 ` Kent Gibson
2022-07-08 11:34 ` [PATCH V4 3/8] libgpiod-sys: Add support to generate gpiosim bindings Viresh Kumar
2022-07-27 2:57 ` Kent Gibson
2022-07-27 5:30 ` Viresh Kumar
2022-07-08 11:34 ` [PATCH V4 4/8] libgpiod: Add rust wrapper crate Viresh Kumar
2022-07-27 2:57 ` Kent Gibson
2022-07-27 9:07 ` Viresh Kumar
2022-07-27 10:08 ` Kent Gibson
2022-07-27 11:06 ` Miguel Ojeda
2022-07-27 12:40 ` Kent Gibson
2022-07-27 13:02 ` Miguel Ojeda
2022-07-28 3:11 ` Kent Gibson
2022-07-29 4:40 ` Viresh Kumar
2022-07-28 3:10 ` Kent Gibson
2022-08-01 12:05 ` Viresh Kumar
2022-08-01 13:20 ` Kent Gibson
2022-08-01 13:28 ` Miguel Ojeda
2022-07-28 8:52 ` Viresh Kumar
2022-07-28 9:59 ` Kent Gibson
2022-07-08 11:34 ` [PATCH V4 5/8] libgpiod: Add rust examples Viresh Kumar
2022-07-27 2:58 ` Kent Gibson
2022-07-27 9:23 ` Viresh Kumar
2022-07-27 9:59 ` Kent Gibson
2022-07-27 10:06 ` Viresh Kumar
2022-07-27 10:32 ` Kent Gibson
2022-07-27 10:33 ` Viresh Kumar
2022-07-08 11:34 ` [PATCH V4 6/8] libgpiod: Derive debug traits for few definitions Viresh Kumar
2022-07-27 2:58 ` Kent Gibson [this message]
2022-07-27 6:20 ` Viresh Kumar
2022-07-08 11:35 ` [PATCH V4 7/8] libgpiod: Add rust tests Viresh Kumar
2022-07-27 2:58 ` Kent Gibson
2022-07-27 9:59 ` Viresh Kumar
2022-07-27 10:27 ` Kent Gibson
2022-08-01 11:54 ` Viresh Kumar
2022-08-01 12:38 ` Kent Gibson
2022-08-02 5:44 ` Viresh Kumar
2022-08-02 5:47 ` Kent Gibson
2022-07-08 11:35 ` [PATCH V4 8/8] libgpiod: Integrate building of rust bindings with make Viresh Kumar
2022-07-27 2:59 ` Kent Gibson
2022-07-27 6:18 ` Viresh Kumar
2022-07-27 6:25 ` Kent Gibson
2022-07-27 6:35 ` Viresh Kumar
2022-07-27 6:45 ` Kent Gibson
2022-07-27 6:51 ` Viresh Kumar
2022-07-15 19:07 ` [PATCH V4 0/8] libgpiod: Add Rust bindings Bartosz Golaszewski
2022-07-15 19:17 ` Miguel Ojeda
2022-07-15 19:27 ` Miguel Ojeda
2022-07-16 9:43 ` Miguel Ojeda
2022-07-16 10:43 ` Bartosz Golaszewski
2022-07-16 12:23 ` Kent Gibson
2022-07-16 13:46 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220727025832.GF88787@sol \
--to=warthog618@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=brgl@bgdev.pl \
--cc=g.m0n3y.2503@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=stratos-dev@op-lists.linaro.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
--cc=wedsonaf@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).