Skip to content

Commit 15eb2e1

Browse files
authored
Use io::ErrorKind::OutOfMemory for xz2/bzip2 codecs (#387)
* Use error kind OutOfMemory for bzip2 encoder Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Use OutOfMem for bzip2 decoder Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Use OutOfMem for xz2 decoder Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Use OutOfMem for xz2 encoder Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Use OutOfMem for bzip2 encoder There were some I missed Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * Fix bzip2 encoder.rs syntax error Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
1 parent fcd9e87 commit 15eb2e1

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

crates/compression-codecs/src/bzip2/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Decode for BzDecoder {
8080

8181
// There was insufficient memory in the input or output buffer to complete
8282
// the request, but otherwise everything went normally.
83-
Status::MemNeeded => Err(io::Error::other("out of memory")),
83+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
8484
}
8585
}
8686

crates/compression-codecs/src/bzip2/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Encode for BzEncoder {
9191

9292
// There was insufficient memory in the input or output buffer to complete
9393
// the request, but otherwise everything went normally.
94-
Status::MemNeeded => Err(io::Error::other("out of memory")),
94+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
9595
}
9696
}
9797

@@ -117,7 +117,7 @@ impl Encode for BzEncoder {
117117

118118
// There was insufficient memory in the input or output buffer to complete
119119
// the request, but otherwise everything went normally.
120-
Status::MemNeeded => Err(io::Error::other("out of memory")),
120+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
121121
}
122122
}
123123

@@ -143,7 +143,7 @@ impl Encode for BzEncoder {
143143

144144
// There was insufficient memory in the input or output buffer to complete
145145
// the request, but otherwise everything went normally.
146-
Status::MemNeeded => Err(io::Error::other("out of memory")),
146+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
147147
}
148148
}
149149
}

crates/compression-codecs/src/xz2/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Decode for Xz2Decoder {
7575
Status::Ok => Ok(false),
7676
Status::StreamEnd => Ok(true),
7777
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
78-
Status::MemNeeded => Err(io::Error::other("More memory needed")),
78+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
7979
}
8080
}
8181

@@ -103,7 +103,7 @@ impl Decode for Xz2Decoder {
103103
Status::Ok => Ok(false),
104104
Status::StreamEnd => Ok(true),
105105
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
106-
Status::MemNeeded => Err(io::Error::other("More memory needed")),
106+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
107107
}
108108
}
109109
}

crates/compression-codecs/src/xz2/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Encode for Xz2Encoder {
9595
match status {
9696
Status::Ok | Status::StreamEnd => Ok(()),
9797
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
98-
Status::MemNeeded => Err(io::Error::other("out of memory")),
98+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
9999
}
100100
}
101101

@@ -120,7 +120,7 @@ impl Encode for Xz2Encoder {
120120
Status::Ok => Ok(false),
121121
Status::StreamEnd => Ok(true),
122122
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
123-
Status::MemNeeded => Err(io::Error::other("out of memory")),
123+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
124124
}
125125
}
126126

@@ -140,7 +140,7 @@ impl Encode for Xz2Encoder {
140140
Status::Ok => Ok(false),
141141
Status::StreamEnd => Ok(true),
142142
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
143-
Status::MemNeeded => Err(io::Error::other("out of memory")),
143+
Status::MemNeeded => Err(io::ErrorKind::OutOfMemory.into()),
144144
}
145145
}
146146
}

0 commit comments

Comments
 (0)