Skip to content

Commit

Permalink
Fix wrong name convention
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Jun 27, 2023
1 parent df32604 commit f4be606
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bindings/unstable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pyo3::{intern, prelude::*, types::PyList};

use external_bindings::slog::{Py_Logger_Mut, Py_Logger_Ref};
use external_bindings::slog::Py_Logger_Mut;
use raftpb_bindings::{
entry::{Py_Entry_Mut, Py_Entry_Ref},
snapshot::{Py_Snapshot_Mut, Py_Snapshot_Ref},
Expand Down
26 changes: 13 additions & 13 deletions src/py_storage_bindings/py_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use raftpb_bindings::snapshot::{Py_Snapshot_Mut, Py_Snapshot_Ref};

use bindings::raft_state::{Py_RaftState_Mut, Py_RaftState_Ref};
use raftpb_bindings::entry::Py_Entry_Mut;
use utils::errors::{makeNativeRaftError, Py_RaftError, DESTROYED_ERR_MSG};
use utils::errors::{make_native_raft_error, Py_RaftError, DESTROYED_ERR_MSG};
use utils::reference::{RefMutContainer, RefMutOwner};
use utils::unsafe_cast::make_mut;

Expand Down Expand Up @@ -209,7 +209,7 @@ impl Storage for Py_Storage {
.extract::<_>()
.map(|rs: Py_RaftState_Mut| rs.into())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}

Expand All @@ -234,7 +234,7 @@ impl Storage for Py_Storage {
.extract::<Vec<Py_Entry_Mut>>()
.map(|entries| entries.into_iter().map(|e| e.into()).collect())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}

Expand All @@ -244,7 +244,7 @@ impl Storage for Py_Storage {
.as_ref(py)
.call_method("term", (idx,), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}

Expand All @@ -254,7 +254,7 @@ impl Storage for Py_Storage {
.as_ref(py)
.call_method("first_index", (), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}

Expand All @@ -264,7 +264,7 @@ impl Storage for Py_Storage {
.as_ref(py)
.call_method("last_index", (), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}

Expand All @@ -278,7 +278,7 @@ impl Storage for Py_Storage {
.extract::<_>()
.map(|ss: Py_Snapshot_Mut| ss.into())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
}
}
Expand All @@ -296,7 +296,7 @@ impl Storage for Py_Storage_Ref {
.extract::<_>(py)
.map(|rs: Py_RaftState_Mut| rs.into())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand Down Expand Up @@ -326,7 +326,7 @@ impl Storage for Py_Storage_Ref {
.extract::<Vec<Py_Entry_Mut>>()
.map(|entries| entries.into_iter().map(|e| e.into()).collect())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand All @@ -341,7 +341,7 @@ impl Storage for Py_Storage_Ref {
.as_ref(py)
.call_method("term", (idx,), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand All @@ -356,7 +356,7 @@ impl Storage for Py_Storage_Ref {
.as_ref(py)
.call_method("first_index", (), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand All @@ -371,7 +371,7 @@ impl Storage for Py_Storage_Ref {
.as_ref(py)
.call_method("last_index", (), None)
.and_then(|term| term.extract::<u64>())
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand All @@ -389,7 +389,7 @@ impl Storage for Py_Storage_Ref {
.extract::<_>(py)
.map(|ss: Py_Snapshot_Mut| ss.into())
})
.map_err(|e| makeNativeRaftError(py, e))
.map_err(|e| make_native_raft_error(py, e))
})
})
.expect(DESTROYED_ERR_MSG)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl From<Py_StorageError> for PyErr {

// Convert 'PyErr' to 'raft::Error' for passing the error to raft-rs
// TODO: Complete below error handling logics.
pub fn makeNativeRaftError(py: Python, py_err: PyErr) -> raft::Error {
pub fn make_native_raft_error(py: Python, py_err: PyErr) -> raft::Error {
let args = py_err.to_object(py).getattr(py, "args").unwrap();
let args = args.downcast::<PyTuple>(py).unwrap();

Expand Down Expand Up @@ -166,7 +166,7 @@ pub fn makeNativeRaftError(py: Python, py_err: PyErr) -> raft::Error {

if py_err.is_instance_of::<StoreError>(py) {
let err_kind = args.get_item(0).unwrap();
return makeNativeStorageError(py_err, err_kind);
return make_native_storage_error(py_err, err_kind);
}

if py_err.is_instance_of::<CodecError>(py) {
Expand All @@ -177,7 +177,7 @@ pub fn makeNativeRaftError(py: Python, py_err: PyErr) -> raft::Error {
panic!("Unreachable")
}

fn makeNativeStorageError(py_err: PyErr, err_kind: &PyAny) -> raft::Error {
fn make_native_storage_error(py_err: PyErr, err_kind: &PyAny) -> raft::Error {
if err_kind.is_instance_of::<CompactedError>() {
return raft::Error::Store(raft::StorageError::Compacted);
}
Expand Down
3 changes: 1 addition & 2 deletions src/utils/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// RefMutContainer implementation is greatly inspired from huggingface/tokenizer's python binding's.
// https://github.com/huggingface/tokenizers/blob/main/bindings/python/src/utils/mod.rs
use pyo3::prelude::*;
use std::ops::Deref;
use std::ops::DerefMut;
use std::ops::{Deref, DerefMut};
use std::ptr::NonNull;
use std::sync::{Arc, Mutex, Weak};

Expand Down

0 comments on commit f4be606

Please sign in to comment.