mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Use lz4-compression instead of lz4-compress
This commit is contained in:
@@ -11,7 +11,7 @@ license = "MIT"
|
||||
[dependencies]
|
||||
bincode = "1.1"
|
||||
bitflags = "1.1"
|
||||
lz4-compress = "0.1.1"
|
||||
lz4-compression = "0.7"
|
||||
num-bigint = { version = "0.3", features = ["serde"] }
|
||||
num-complex = { version = "0.2", features = ["serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -409,14 +409,15 @@ impl CodeObject {
|
||||
|
||||
/// Load a code object from bytes
|
||||
pub fn from_bytes(data: &[u8]) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let data = lz4_compress::decompress(data)?;
|
||||
let data = lz4_compression::decompress::decompress(data)
|
||||
.map_err(|e| format!("lz4 error: {:?}", e))?;
|
||||
bincode::deserialize::<Self>(&data).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
/// Serialize this bytecode to bytes.
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
let data = bincode::serialize(&self).expect("Code object must be serializable");
|
||||
lz4_compress::compress(&data)
|
||||
lz4_compression::compress::compress(&data)
|
||||
}
|
||||
|
||||
pub fn get_constants(&self) -> impl Iterator<Item = &Constant> {
|
||||
|
||||
Reference in New Issue
Block a user