Skip to content

Commit f563eba

Browse files
committed
add BufferToSmall error case to FFIResult kind
1 parent 76b135f commit f563eba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bindings/src/error.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub enum Kind {
3636
Ok,
3737
EmptyPointerProvided,
3838
InvalidSeedLength,
39+
/// Return this when buffer for allocating error message is too small.
40+
/// When this is the last error, the caller should try to increase the buffer size and call the function again.
41+
BufferTooSmall,
3942
InternalError,
4043
}
4144

@@ -133,6 +136,14 @@ impl FFIResult {
133136
self.kind == Kind::EmptyPointerProvided
134137
}
135138

139+
pub(super) fn buffer_too_small() -> Self {
140+
FFIResult { kind: Kind::BufferTooSmall, id: next_err_id() }
141+
}
142+
143+
pub fn is_buffer_too_small(&self) -> bool {
144+
self.kind == Kind::BufferTooSmall
145+
}
146+
136147
pub(super) fn invalid_seed_length() -> Self {
137148
FFIResult { kind: Kind::InvalidSeedLength, id: next_err_id() }
138149
}
@@ -157,6 +168,7 @@ impl FFIResult {
157168
Kind::EmptyPointerProvided => Some("a required pointer argument was null"),
158169
Kind::InvalidSeedLength => Some("provided seed buffer has invalid length"),
159170
Kind::InternalError => Some("An internal error occured"),
171+
Kind::BufferTooSmall => Some("buffer was too small"),
160172
}
161173
}
162174

0 commit comments

Comments
 (0)