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

Investigate callback-based API #43

Open
robin-nitrokey opened this issue Jun 17, 2024 · 0 comments
Open

Investigate callback-based API #43

robin-nitrokey opened this issue Jun 17, 2024 · 0 comments

Comments

@robin-nitrokey
Copy link
Member

To avoid the need for owned Response types, we should investigate the use of a callback-based API in the Authenticator traits:

pub trait Authenticator {
    fn call_ctap2(&mut self, request: &Request<'_>, responder: ResponseBuilder<'_>) -> Result<Token<Operation>>;
}

Or:

pub trait Authenticator {
    fn call_ctap2<F>(&mut self, request: &Request<'_>, responder: F) -> Result<Token<Operation>>
    where
        F: impl FnOnce(&Response) -> Token<Operation>;
}

We could still enforce that exactly one response of the correct type is generated by consuming the responder and producing a Token that needs to be returned.

Goals:

  • avoid allocations
  • reduce stack usage and binary size
  • reduce code duplication in ctap-types (owned and borrowed)
  • reduce the need for fixed-sized buffers (reduce maintenance and complexity)
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

No branches or pull requests

1 participant