pub fn credentials(&mut self, credentials: &Credentials)
        -> Result<&mut Self, Error>
    {
        let mut cert = rustls::RootCertStore::empty();
        let pem;
        if let Some(cert_data) = &credentials.tls_cert_data {
            pem = Some(cert_data.clone());
            match
                cert.add_pem_file(&mut io::Cursor::new(cert_data.as_bytes()))
            {
                Ok((0, 0)) => {
                    return Err(ClientError::with_message(
                        "Empty certificate data"));
                }
                Ok((_, 0)) => {}
                Ok((_, _)) | Err(()) => {
                    return Err(ClientError::with_message(
                        "Invalid certificates are contained in `tls_certdata`"
                    ));
                }
            }
        } else {
            pem = None;
        }
        self.reset_compound();
        self.host = credentials.host.clone()
                .unwrap_or_else(|| DEFAULT_HOST.into());
        self.port = credentials.port;
        self.admin = false;
        self.user = credentials.user.clone();
        self.password = credentials.password.clone();
        self.database = credentials.database.clone()
                .unwrap_or_else(|| "edgedb".into());
        self.creds_file_outdated = credentials.file_outdated;
        self.tls_security = credentials.tls_security;
        self.cert = cert;
        self.pem = pem;
        self.initialized = true;
        Ok(self)
    }
/// Set all credentials.
///
/// This marks the builder as initialized.
Set all credentials.
This marks the builder as initialized.
Set all credentials . This marks the builder as initialized .
pub fn credentials(&mut self, credentials: &Credentials)
        -> Result<&mut Self, Error>
    {
        let mut cert = rustls::RootCertStore::empty();
        let pem;
        if let Some(cert_data) = &credentials.tls_cert_data {
            pem = Some(cert_data.clone());
            match
                cert.add_pem_file(&mut io::Cursor::new(cert_data.as_bytes()))
            {
                Ok((0, 0)) => {
                    return Err(ClientError::with_message(
                        "Empty certificate data"));
                }
                Ok((_, 0)) => {}
                Ok((_, _)) | Err(()) => {
                    return Err(ClientError::with_message(
                        "Invalid certificates are contained in `tls_certdata`"
                    ));
                }
            }
        } else {
            pem = None;
        }
        self.reset_compound();
        self.host = credentials.host.clone()
                .unwrap_or_else(|| DEFAULT_HOST.into());
        self.port = credentials.port;
        self.admin = false;
        self.user = credentials.user.clone();
        self.password = credentials.password.clone();
        self.database = credentials.database.clone()
                .unwrap_or_else(|| "edgedb".into());
        self.creds_file_outdated = credentials.file_outdated;
        self.tls_security = credentials.tls_security;
        self.cert = cert;
        self.pem = pem;
        self.initialized = true;
        Ok(self)
    }
pub fn credentials ( & mut self , credentials : & Credentials ) -> Result < & mut Self , Error > { let mut cert = rustls :: RootCertStore :: empty ( ) ; let pem ; if let Some ( cert_data ) = & credentials . tls_cert_data { pem = Some ( cert_data . clone ( ) ) ; match cert . add_pem_file ( & mut io :: Cursor :: new ( cert_data . as_bytes ( ) ) ) { Ok ( ( 0 , 0 ) ) => { return Err ( ClientError :: with_message ( " " ) ) ; } Ok ( ( _ , 0 ) ) => { } Ok ( ( _ , _ ) ) | Err ( ( ) ) => { return Err ( ClientError :: with_message ( " " ) ) ; } } } else { pem = None ; } self . reset_compound ( ) ; self . host = credentials . host . clone ( ) . unwrap_or_else ( | | DEFAULT_HOST . into ( ) ) ; self . port = credentials . port ; self . admin = false ; self . user = credentials . user . clone ( ) ; self . password = credentials . password . clone ( ) ; self . database = credentials . database . clone ( ) . unwrap_or_else ( | | " " . into ( ) ) ; self . creds_file_outdated = credentials . file_outdated ; self . tls_security = credentials . tls_security ; self . cert = cert ; self . pem = pem ; self . initialized = true ; Ok ( self ) }
Set all credentials.
Set all credentials .
&mut self
credentials
&Credentials