-
Notifications
You must be signed in to change notification settings - Fork 59
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
load_certs_from_path #148
base: main
Are you sure you want to change the base?
load_certs_from_path #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me.
src/lib.rs
Outdated
/// hash files contained in it must be loaded successfully, | ||
/// subject to the rules outlined above for `file`. The directory is not | ||
/// scanned recursively and may be empty. | ||
pub fn load_certs_from_path<T: AsRef<Path>>(file: Option<T>, dir: Option<T>) -> CertificateResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe paths
instead of path
? Also I would spell this as file: Option<impl AsRef<Path>>, dir: Option<impl AsRef<Path>>
since there is no reason to require that both types are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use impl
here then the caller has to manually specify a type any time they use None
for one of the arguments. ie load_certs_from_path(None, Some("/tmp"))
would need to be written like load_certs_from_path(Option::<&str>::None, Some("/tmp"))
, whereas using the same T
generic for both means itll auto-resolve as long as at least one argument is Some
. I figured that would be less annoying for the caller, but i agree it is more limiting and i can change this to use impl
if you think its best!
(edit: accidentally said dyn
instead of impl
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually now that i think about it more, if the caller is using two different types that satisfy AsRef<T>
, then they can just convert them to paths on their end before passing them. which i think is less of a hassle than having to always specify Option::<&str>::None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this, I'd suggest we just change them both to Option<&Path>
and give up on coercion via AsRef
. Personally I still don't like that we enforce the same type for both arguments because IMO this suggests something that really doesn't make sense (although it does work it if you just pass &Path
, of course).
Thanks for the PR 👍 I think this docs failure in CI could use a fix:
If you wouldn't mind it would also be nice to have the commits squashed down to 1 with a good commit message. |
change name to load_certs_from_paths revert fn signature to use generic forgot to change fn name CertPaths::load address comments about docs
I believe i addressed everything. I'll let you guys merge this when you think its all good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM
This PR offers a solution for #147 by moving
CertPaths::load
to the public functionload_certs_from_path