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

Simplify ApplyTcpOptionsError #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pronebird
Copy link

@pronebird pronebird commented May 4, 2024

ApplyTcpOptionsErrorInternal is superficial and can be replaced with a Box<>, especially because std::error::Error::source() returns Option<&dyn std::error::Error>. Identical approach is already used in std::io::Error, so familiarity bonus point here.

Improvements in this PR

  • Remove variant mirroring between ApplyTcpOptionsErrorKind and ApplyTcpOptionsErrorInternal.
  • RemoveApplyTcpOptionsErrorInternal.

Further thoughts

  • ApplyTcpOptionsError::new(.., ..) is a bit verbose, mostly because of how types are called. I thought of droppingApplyTcpOptions from error-related type names to avoid repeating the module name in it. However I didn't quite agree with myself that this is an improvement.

  • tcp_options::* are re-exported in lib.rs, hard to say why this module gets a special treatment, but then I don't know much about the use cases here. Maybe the consumer of this library needs to set socket options frequently.

  • There is a performance impact when using Box and dynamic dispatch. But this is negligible since error code paths should not be traversed frequently.


This change is Reviewable

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.

1 participant