Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMaul committed Sep 11, 2024
1 parent 4852aaf commit 015fcc6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,19 @@ pub enum PkEncryptionError {
Decode(#[from] vodozemac::pk_encryption::Error),
}

pyo3::create_exception!(module, PkInvalidKeySizeException, pyo3::exceptions::PyValueError);
pyo3::create_exception!(
module,
PkInvalidKeySizeException,
pyo3::exceptions::PyValueError
);
pyo3::create_exception!(module, PkDecodeException, pyo3::exceptions::PyValueError);

impl From<PkEncryptionError> for PyErr {
fn from(e: PkEncryptionError) -> Self {
match e {
PkEncryptionError::InvalidKeySize(_) => PkInvalidKeySizeException::new_err(e.to_string()),
PkEncryptionError::InvalidKeySize(_) => {
PkInvalidKeySizeException::new_err(e.to_string())
}
PkEncryptionError::Decode(_) => PkDecodeException::new_err(e.to_string()),
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/pk_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use pyo3::{
Bound, Py, Python,
};

use crate::{types::{Curve25519PublicKey, Curve25519SecretKey}, PkEncryptionError};
use crate::{
types::{Curve25519PublicKey, Curve25519SecretKey},
PkEncryptionError,
};

/// A message that was encrypted using a PkEncryption object.
#[pyclass]
Expand Down Expand Up @@ -48,7 +51,10 @@ impl PkDecryption {

/// Create a PkDecryption object from the secret key bytes.
#[classmethod]
fn from_key(_cls: &Bound<'_, PyType>, key: Curve25519SecretKey) -> Result<Self, PkEncryptionError> {
fn from_key(
_cls: &Bound<'_, PyType>,
key: Curve25519SecretKey,
) -> Result<Self, PkEncryptionError> {
Ok(Self {
inner: vodozemac::pk_encryption::PkDecryption::from_key(key.inner),
})
Expand Down

0 comments on commit 015fcc6

Please sign in to comment.