Skip to content

Commit

Permalink
fix: use parameter destructuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gboutry committed Feb 22, 2022
1 parent 2558ec5 commit c2eefaa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
8 changes: 5 additions & 3 deletions crates/krb5_js/src/kdestroy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ pub struct KdestroyParameters {
pub ccname: Option<String>,
}

pub fn kdestroy_function(options: &mut KdestroyParameters) -> std::result::Result<(), Error> {
pub fn kdestroy_function(
KdestroyParameters { ccname }: &mut KdestroyParameters,
) -> std::result::Result<(), Error> {
let context = Context::new()?;
let ccache = match options.ccname {
let ccache = match ccname {
Some(ref cc_name) => CCache::resolve(&context, cc_name)?,
None => CCache::default(&context)?,
};
Expand All @@ -33,7 +35,7 @@ impl Task for Kdestroy {
fn compute(&mut self) -> napi::Result<Self::Output> {
kdestroy_function(&mut self.input).map_err(napi::Error::from)
}

fn resolve(&mut self, env: Env, _output: Self::Output) -> napi::Result<Self::JsValue> {
env.get_undefined()
}
Expand Down
7 changes: 4 additions & 3 deletions crates/krb5_js/src/kinit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ pub struct KinitParameters {
pub ccname: Option<String>,
}

pub fn kinit_function(parameters: &mut KinitParameters) -> Result<String, Error> {
let KinitParameters {
pub fn kinit_function(
KinitParameters {
principal,
password,
keytab,
realm,
ccname,
} = parameters;
}: &mut KinitParameters,
) -> Result<String, Error> {
if password.is_none() && keytab.is_none() {
return Err(Error::MissingPasswordOrKeytab);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/krb5_js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn kinit(input: KinitParameters) -> AsyncTask<Kinit> {
AsyncTask::new(Kinit { input })
}

#[napi(ts_return_type="Promise<void>")]
#[napi(ts_return_type = "Promise<void>")]
pub fn kdestroy(input: KdestroyParameters) -> AsyncTask<Kdestroy> {
AsyncTask::new(Kdestroy { input })
}
Expand Down
8 changes: 3 additions & 5 deletions crates/krb5_js/src/spnego.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ pub struct GenerateSpnegoTokenParameters {
}

pub fn generate_spnego_token_function(
options: &mut GenerateSpnegoTokenParameters,
) -> std::result::Result<String, String> {
let GenerateSpnegoTokenParameters {
GenerateSpnegoTokenParameters {
service_principal,
service_fqdn,
hostbased_service,
ccname,
} = options;

}: &mut GenerateSpnegoTokenParameters,
) -> std::result::Result<String, String> {
let (service_principal, input_name_type) = if let Some(service) = service_principal {
(service.to_owned(), "GSS_C_NT_USER_NAME")
} else {
Expand Down

0 comments on commit c2eefaa

Please sign in to comment.