summaryrefslogtreecommitdiff
path: root/ext/web/lib.rs
diff options
context:
space:
mode:
authorAndreu Botella <andreu@andreubotella.com>2022-05-13 10:36:31 +0200
committerGitHub <noreply@github.com>2022-05-13 10:36:31 +0200
commit3e7afb8918fd0f6cedf839a7ebaae6aaee5e66ad (patch)
tree7fcc92da290889d3d2290f6e4902ac60685aae87 /ext/web/lib.rs
parent0ee76da07b12fba38962634e65853d73adf9d4c0 (diff)
chore(runtime): Make some ops in ext and runtime infallible. (#14589)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
Diffstat (limited to 'ext/web/lib.rs')
-rw-r--r--ext/web/lib.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/web/lib.rs b/ext/web/lib.rs
index d14a4a5d5..0d57bf10e 100644
--- a/ext/web/lib.rs
+++ b/ext/web/lib.rs
@@ -180,13 +180,13 @@ fn b64_decode(input: &[u8]) -> Result<Vec<u8>, AnyError> {
}
#[op]
-fn op_base64_encode(s: ZeroCopyBuf) -> Result<String, AnyError> {
- Ok(b64_encode(&s))
+fn op_base64_encode(s: ZeroCopyBuf) -> String {
+ b64_encode(&s)
}
#[op]
-fn op_base64_btoa(s: ByteString) -> Result<String, AnyError> {
- Ok(b64_encode(s))
+fn op_base64_btoa(s: ByteString) -> String {
+ b64_encode(s)
}
fn b64_encode(s: impl AsRef<[u8]>) -> String {
@@ -323,7 +323,7 @@ struct EncodeIntoResult {
fn op_encoding_encode_into(
input: String,
mut buffer: ZeroCopyBuf,
-) -> Result<EncodeIntoResult, AnyError> {
+) -> EncodeIntoResult {
// Since `input` is already UTF-8, we can simply find the last UTF-8 code
// point boundary from input that fits in `buffer`, and copy the bytes up to
// that point.
@@ -347,18 +347,17 @@ fn op_encoding_encode_into(
buffer[..boundary].copy_from_slice(input[..boundary].as_bytes());
- Ok(EncodeIntoResult {
+ EncodeIntoResult {
// The `read` output parameter is measured in UTF-16 code units.
read: input[..boundary].encode_utf16().count(),
written: boundary,
- })
+ }
}
/// Creates a [`CancelHandle`] resource that can be used to cancel invocations of certain ops.
#[op]
-pub fn op_cancel_handle(state: &mut OpState) -> Result<ResourceId, AnyError> {
- let rid = state.resource_table.add(CancelHandle::new());
- Ok(rid)
+pub fn op_cancel_handle(state: &mut OpState) -> ResourceId {
+ state.resource_table.add(CancelHandle::new())
}
pub fn get_declaration() -> PathBuf {