Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nss-pam-webapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
magicfelix
nss-pam-webapi
Commits
c96b272e
Verified
Commit
c96b272e
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Make `get_or_error` generic
Thanks to Andreu Botella!
parent
c4fd3260
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/config.rs
+1
-9
1 addition, 9 deletions
src/config.rs
with
1 addition
and
9 deletions
src/config.rs
+
1
−
9
View file @
c96b272e
...
@@ -15,9 +15,6 @@
...
@@ -15,9 +15,6 @@
use
serde
::
de
::
Deserialize
;
use
serde
::
de
::
Deserialize
;
use
pamsm
::
PamError
;
use
libnss
::
interop
::
Response
;
extern
crate
config
;
extern
crate
config
;
const
DEFAULT_CONFIG_FILE
:
&
str
=
"/etc/nss_pam_oidc"
;
const
DEFAULT_CONFIG_FILE
:
&
str
=
"/etc/nss_pam_oidc"
;
...
@@ -73,12 +70,7 @@ pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str)
...
@@ -73,12 +70,7 @@ pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str)
}
}
}
}
enum
DesiredError
{
pub
fn
get_or_error
<
'de
,
T
:
Deserialize
<
'de
>
,
E
>
(
config
:
&
config
::
Config
,
key
:
&
str
,
error_value
:
E
)
->
Result
<
T
,
E
>
{
Response
,
PamError
}
pub
fn
get_or_error
<
'de
,
T
:
Deserialize
<
'de
>>
(
config
:
&
config
::
Config
,
key
:
&
str
,
error_value
:
DesiredError
)
->
Result
<
T
,
Response
>
{
match
get_optional
(
config
,
key
)
{
match
get_optional
(
config
,
key
)
{
Some
(
v
)
=>
{
Some
(
v
)
=>
{
debug!
(
"Configuration key found: {}"
,
key
);
debug!
(
"Configuration key found: {}"
,
key
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment