Struct filecount::memory::HashedMemory
source · [−]pub struct HashedMemory(_);
Expand description
A translation memory optimized in a BinaryTree datastructure for performant analysis Most functions defined in this struct have a segment and a hash variant. This is for convenience only, the segment variants simply make use of the included hashing implementation.
Implementations
sourceimpl HashedMemory
impl HashedMemory
sourcepub fn contains(&self, segment: &str) -> bool
pub fn contains(&self, segment: &str) -> bool
Checks to see if a segment exists in the memory [O(log(n)]
sourcepub fn contains_hash(&self, hash: &u64) -> bool
pub fn contains_hash(&self, hash: &u64) -> bool
Checks to see if the hash of a segment exists in the memory [O(log(n)]
sourcepub fn merge_with(&mut self, other: Self)
pub fn merge_with(&mut self, other: Self)
Merge a second memory into this memory
sourcepub fn from_tmx(buf: &[u8]) -> Result<Self, Box<dyn Error>>
pub fn from_tmx(buf: &[u8]) -> Result<Self, Box<dyn Error>>
Create a HashedMemory from a .tmx file binary.
Examples
let mut memfile = File::open("files/mem.tmx").unwrap();
let mut memciphertext = Vec::new();
memfile.read_to_end(&mut memciphertext).unwrap();
let memory = HashedMemory::from_tmx(&memciphertext).unwrap();
Errors
MemoryParseError: Can be caused by invalid .tmx files. F.e. because the tmx lacks a header or srclang. Other errors: When parsing the .tmx file failed for other reasons.
Trait Implementations
sourceimpl Debug for HashedMemory
impl Debug for HashedMemory
sourceimpl<'de> Deserialize<'de> for HashedMemory
impl<'de> Deserialize<'de> for HashedMemory
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Serialize for HashedMemory
impl Serialize for HashedMemory
Auto Trait Implementations
impl RefUnwindSafe for HashedMemory
impl Send for HashedMemory
impl Sync for HashedMemory
impl Unpin for HashedMemory
impl UnwindSafe for HashedMemory
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more