Make Vertex immutable

To match the C++ implementation. I meant to do this at the same time as the other metadata structs but missed it.
This commit is contained in:
Oliver Hamlet
2025-05-14 18:24:54 +01:00
parent beab02c3fe
commit 517dc6b43c
6 changed files with 60 additions and 78 deletions
+1 -15
View File
@@ -1,5 +1,4 @@
use std::{
hash::{DefaultHasher, Hash, Hasher},
path::PathBuf,
sync::{Arc, RwLock},
};
@@ -225,7 +224,7 @@ impl From<Arc<RwLock<libloot::Database>>> for Database {
}
}
#[pyclass(eq, ord, str = "{0:?}")]
#[pyclass(eq, ord, frozen, hash, str = "{0:?}")]
#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
pub struct Vertex(libloot::Vertex);
@@ -250,13 +249,6 @@ impl Vertex {
.transpose()
}
#[setter]
fn set_out_edge_type(&mut self, out_edge_type: EdgeType) -> Result<(), VerboseError> {
let out_edge_type = out_edge_type.try_into()?;
self.0.set_out_edge_type(out_edge_type);
Ok(())
}
fn __repr__(slf: &Bound<'_, Self>) -> PyResult<String> {
let class_name = slf.get_type().qualname()?;
let inner = &slf.borrow().0;
@@ -267,12 +259,6 @@ impl Vertex {
inner.out_edge_type().map_or(NONE_REPR, repr_edge_type),
))
}
fn __hash__(&self) -> u64 {
let mut hasher = DefaultHasher::new();
self.0.hash(&mut hasher);
hasher.finish()
}
}
impl From<libloot::Vertex> for Vertex {