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

Publicly export ExceptionResponse and Exception types #218

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub use self::slave::{Slave, SlaveId};
mod codec;

mod frame;
pub use self::frame::{Address, FunctionCode, Quantity, Request, Response};
pub use self::frame::{
Address, Exception, ExceptionResponse, FunctionCode, Quantity, Request, Response,
Copy link
Contributor

@benjamin-nw benjamin-nw Dec 22, 2023

Choose a reason for hiding this comment

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

I think we should make ExceptionResponse public but not its fields.

We could change the fields to pub(crate) in order to still be able to access it in the crate.

We should add at least add 2 methods for the ExceptionResponse:

  • exception() that returns the Exception
  • function_code() that returns the FunctionCode

And we should also enable a simple creation of the ExceptionResponse with a new method, or a method on Request / Response maybe to create a ExceptionResponse from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

After thinking about it more, I think only Exception should be in the public API.

The user shouldn't have to know the existence of ExceptionResponse, the server should be able to build the appropriate Response type (either Response or ExceptionResponse) by the return of the call function.

See #237 for more context.

};

mod service;

Expand Down
Loading