Get caching working again

This commit is contained in:
Lachlan Sneff
2019-02-20 16:41:41 -08:00
parent 82eea00a02
commit 9f40eedba8
21 changed files with 244 additions and 246 deletions

View File

@ -10,7 +10,6 @@ pub use self::unix::*;
#[cfg(windows)]
pub use self::windows::*;
use serde::{
de::{self, SeqAccess, Visitor},
ser::SerializeStruct,
@ -21,7 +20,6 @@ use serde_bytes::Bytes;
use std::fmt;
impl Serialize for Memory {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@ -36,7 +34,6 @@ impl Serialize for Memory {
}
}
impl<'de> Deserialize<'de> for Memory {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where

View File

@ -207,16 +207,26 @@ impl Drop for Memory {
impl Clone for Memory {
fn clone(&self) -> Self {
let mut new = Memory::with_size_protect(self.size, self.protection).unwrap();
let temp_protection = if self.protection.is_writable() {
self.protection
} else {
Protect::ReadWrite
};
let mut new = Memory::with_size_protect(self.size, temp_protection).unwrap();
unsafe {
new.as_slice_mut().copy_from_slice(self.as_slice());
if temp_protection != self.protection {
new.protect(.., self.protection).unwrap();
}
}
new
}
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
#[allow(dead_code)]
pub enum Protect {
None,

View File

@ -158,16 +158,26 @@ impl Drop for Memory {
impl Clone for Memory {
fn clone(&self) -> Self {
let mut new = Memory::with_size_protect(self.size, self.protection).unwrap();
let temp_protection = if self.protection.is_writable() {
self.protection
} else {
Protect::ReadWrite
};
let mut new = Memory::with_size_protect(self.size, temp_protection).unwrap();
unsafe {
new.as_slice_mut().copy_from_slice(self.as_slice());
if temp_protection != self.protection {
new.protect(.., self.protection).unwrap();
}
}
new
}
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
#[allow(dead_code)]
pub enum Protect {
None,