pub fn build_principal<'a>(&'a self, realm: &'a str, args: &'a [String]) -> Result<Krb5Principal<'a>, Krb5Error> {
    let crealm = string_to_c_string(realm)?;
    let realml = realm.len() as u32;

    let mut varargs = Vec::new();
    for arg in args {
      varargs.push(string_to_c_string(arg)?);
    }

    let mut principal_ptr: MaybeUninit<krb5_principal> = MaybeUninit::zeroed();

    // TODO: write a macro to generate this match block
    let code: krb5_error_code = match args.len() {
      // varargs support in Rust is lacking, so only support a limited number of arguments for now
      0 => unsafe { krb5_build_principal(self.context, principal_ptr.as_mut_ptr(), realml, crealm) },
      1 => unsafe { krb5_build_principal(self.context, principal_ptr.as_mut_ptr(), realml, crealm, varargs[0]) },
      2 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
        )
      },
      3 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
          varargs[2],
        )
      },
      4 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
          varargs[2],
          varargs[3],
        )
      },
      _ => return Err(Krb5Error::MaxVarArgsExceeded),
    };

    krb5_error_code_escape_hatch(self, code)?;

    let principal = Krb5Principal {
      context: self,
      principal: unsafe { principal_ptr.assume_init() },
    };

    Ok(principal)
  }
/**
   * Build a principal name using a realm and 1 or more strings.
   *
   * Wraps [krb5_build_principal](https://web.mit.edu/kerberos/krb5-1.16/doc/appdev/refs/api/krb5_build_principal.html)
   */
Build a principal name using a realm and 1 or more strings.
Build a principal name using a realm and 1 or more strings .
pub fn build_principal<'a>(&'a self, realm: &'a str, args: &'a [String]) -> Result<Krb5Principal<'a>, Krb5Error> {
    let crealm = string_to_c_string(realm)?;
    let realml = realm.len() as u32;
    let mut varargs = Vec::new();
    for arg in args {
      varargs.push(string_to_c_string(arg)?);
    }
    let mut principal_ptr: MaybeUninit<krb5_principal> = MaybeUninit::zeroed();
    // TODO: write a macro to generate this match block
    let code: krb5_error_code = match args.len() {
      // varargs support in Rust is lacking, so only support a limited number of arguments for now
      0 => unsafe { krb5_build_principal(self.context, principal_ptr.as_mut_ptr(), realml, crealm) },
      1 => unsafe { krb5_build_principal(self.context, principal_ptr.as_mut_ptr(), realml, crealm, varargs[0]) },
      2 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
        )
      },
      3 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
          varargs[2],
        )
      },
      4 => unsafe {
        krb5_build_principal(
          self.context,
          principal_ptr.as_mut_ptr(),
          realml,
          crealm,
          varargs[0],
          varargs[1],
          varargs[2],
          varargs[3],
        )
      },
      _ => return Err(Krb5Error::MaxVarArgsExceeded),
    };
    krb5_error_code_escape_hatch(self, code)?;
    let principal = Krb5Principal {
      context: self,
      principal: unsafe { principal_ptr.assume_init() },
    };
    Ok(principal)
  }
pub fn build_principal < ' a > ( & ' a self , realm : & ' a str , args : & ' a [ String ] ) -> Result < Krb5Principal < ' a > , Krb5Error > { let crealm = string_to_c_string ( realm ) ? ; let realml = realm . len ( ) as u32 ; let mut varargs = Vec :: new ( ) ; for arg in args { varargs . push ( string_to_c_string ( arg ) ? ) ; } let mut principal_ptr : MaybeUninit < krb5_principal > = MaybeUninit :: zeroed ( ) ; // TODO: write a macro to generate this match block let code : krb5_error_code = match args . len ( ) { // varargs support in Rust is lacking, so only support a limited number of arguments for now 0 => unsafe { krb5_build_principal ( self . context , principal_ptr . as_mut_ptr ( ) , realml , crealm ) } , 1 => unsafe { krb5_build_principal ( self . context , principal_ptr . as_mut_ptr ( ) , realml , crealm , varargs [ 0 ] ) } , 2 => unsafe { krb5_build_principal ( self . context , principal_ptr . as_mut_ptr ( ) , realml , crealm , varargs [ 0 ] , varargs [ 1 ] , ) } , 3 => unsafe { krb5_build_principal ( self . context , principal_ptr . as_mut_ptr ( ) , realml , crealm , varargs [ 0 ] , varargs [ 1 ] , varargs [ 2 ] , ) } , 4 => unsafe { krb5_build_principal ( self . context , principal_ptr . as_mut_ptr ( ) , realml , crealm , varargs [ 0 ] , varargs [ 1 ] , varargs [ 2 ] , varargs [ 3 ] , ) } , _ => return Err ( Krb5Error :: MaxVarArgsExceeded ) , } ; krb5_error_code_escape_hatch ( self , code ) ? ; let principal = Krb5Principal { context : self , principal : unsafe { principal_ptr . assume_init ( ) } , } ; Ok ( principal ) }
Build a principal name using a realm and 1 or more strings.
Build a principal name using a realm and 1 or more strings .
&'a self
realm
&'a str
args
&'a [String]