Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement query for lirc programs #32

Merged
merged 1 commit into from
Jul 27, 2021
Merged

Conversation

seanyoung
Copy link
Contributor

Signed-off-by: Sean Young sean@mess.org

@seanyoung
Copy link
Contributor Author

Fixes #2

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Overall I like this approach and I think it will work for other programs as well.

aya/src/programs/lirc_mode2.rs Outdated Show resolved Hide resolved
aya/src/programs/lirc_mode2.rs Show resolved Hide resolved
@seanyoung seanyoung force-pushed the query branch 2 times, most recently from b35522d to d2c911f Compare July 26, 2021 12:50
pub struct ProgramInfo(bpf_prog_info);

impl ProgramInfo {
pub fn name(&self) -> Option<String> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this return &[u8]? It's valid for the name not to be utf8, I think callers should (optionally) do the conversion here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this return &[u8]? It's valid for the name not to be utf8, I think callers should (optionally) do the conversion here

I just realised that we use String for program names everywhere else so I'm leaving this up to you, I'm ok with either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have both of them now as an option: fn name() which gives you &[u8] and fn name_as_str() which returns Option<&str>.

@@ -533,3 +579,24 @@ impl_try_from_program!(
CgroupSkb,
LircMode2
);

pub struct ProgramInfo(bpf_prog_info);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some docs for the struct and the accessors please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some rustdoc (a bit rudimentary)

Signed-off-by: Sean Young <sean@mess.org>
@alessandrod alessandrod merged commit 81e07e9 into aya-rs:main Jul 27, 2021
@alessandrod
Copy link
Collaborator

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants