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

Allow not setting a string descriptor #53

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

roblabla
Copy link
Contributor

Most devices don't actually set interface descriptors or manufacturer/product name/serial numbers - instead leaving all those strings to 0, likely to save up on space.

I want to test drivers to make sure they react properly to either missing or presence of string descriptor, so I need to have control over whether a string is there or not.

With this MR, all strings start by being unset, and the various functions to set a string now take an Option<&str>, with None meaning 0/no string descriptor.

This is an API-breaking change.

pub fn set_configuration_name(&mut self, name: &str) -> Option<String> {
self.string_pool
.insert(self.string_configuration, name.to_string())
pub fn set_configuration_name(&mut self, name: Option<&str>) -> Option<String> {
Copy link
Owner

Choose a reason for hiding this comment

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

I think it is unclear, maybe we should use two apis for set & clear?

@jiegec jiegec merged commit 458cc08 into jiegec:master Oct 26, 2024
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.

2 participants