pub struct HashedMemory(/* private fields */);
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§
Source§impl 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§
Source§impl Debug for HashedMemory
impl Debug for HashedMemory
Source§impl<'de> Deserialize<'de> for HashedMemory
impl<'de> Deserialize<'de> for HashedMemory
Source§fn 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
Auto Trait Implementations§
impl Freeze for HashedMemory
impl RefUnwindSafe for HashedMemory
impl Send for HashedMemory
impl Sync for HashedMemory
impl Unpin for HashedMemory
impl UnwindSafe for HashedMemory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more