diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/url/lib.rs | 6 | ||||
-rw-r--r-- | ext/web/blob.rs | 11 | ||||
-rw-r--r-- | ext/web/compression.rs | 4 | ||||
-rw-r--r-- | ext/web/lib.rs | 19 | ||||
-rw-r--r-- | ext/web/message_port.rs | 4 | ||||
-rw-r--r-- | ext/web/timers.rs | 19 |
6 files changed, 24 insertions, 39 deletions
diff --git a/ext/url/lib.rs b/ext/url/lib.rs index 394fd5902..be229cec5 100644 --- a/ext/url/lib.rs +++ b/ext/url/lib.rs @@ -160,13 +160,11 @@ pub fn op_url_parse_search_params( } #[op] -pub fn op_url_stringify_search_params( - args: Vec<(String, String)>, -) -> Result<String, AnyError> { +pub fn op_url_stringify_search_params(args: Vec<(String, String)>) -> String { let search = form_urlencoded::Serializer::new(String::new()) .extend_pairs(args) .finish(); - Ok(search) + search } pub fn get_declaration() -> PathBuf { diff --git a/ext/web/blob.rs b/ext/web/blob.rs index 43121ee3a..7da42e178 100644 --- a/ext/web/blob.rs +++ b/ext/web/blob.rs @@ -163,11 +163,10 @@ impl BlobPart for SlicedBlobPart { pub fn op_blob_create_part( state: &mut deno_core::OpState, data: ZeroCopyBuf, -) -> Result<Uuid, AnyError> { +) -> Uuid { let blob_store = state.borrow::<BlobStore>(); let part = InMemoryBlobPart(data.to_vec()); - let id = blob_store.insert_part(Arc::new(part)); - Ok(id) + blob_store.insert_part(Arc::new(part)) } #[derive(Deserialize)] @@ -219,13 +218,9 @@ pub async fn op_blob_read_part( } #[op] -pub fn op_blob_remove_part( - state: &mut deno_core::OpState, - id: Uuid, -) -> Result<(), AnyError> { +pub fn op_blob_remove_part(state: &mut deno_core::OpState, id: Uuid) { let blob_store = state.borrow::<BlobStore>(); blob_store.remove_part(&id); - Ok(()) } #[op] diff --git a/ext/web/compression.rs b/ext/web/compression.rs index f5ee38257..9f5fcb813 100644 --- a/ext/web/compression.rs +++ b/ext/web/compression.rs @@ -38,7 +38,7 @@ pub fn op_compression_new( state: &mut OpState, format: String, is_decoder: bool, -) -> Result<ResourceId, AnyError> { +) -> ResourceId { let w = Vec::new(); let inner = match (format.as_str(), is_decoder) { ("deflate", true) => Inner::DeflateDecoder(ZlibDecoder::new(w)), @@ -52,7 +52,7 @@ pub fn op_compression_new( _ => unreachable!(), }; let resource = CompressionResource(RefCell::new(inner)); - Ok(state.resource_table.add(resource)) + state.resource_table.add(resource) } #[op] 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 { diff --git a/ext/web/message_port.rs b/ext/web/message_port.rs index b193e6b9b..06f7e3c52 100644 --- a/ext/web/message_port.rs +++ b/ext/web/message_port.rs @@ -109,7 +109,7 @@ impl Resource for MessagePortResource { #[op] pub fn op_message_port_create_entangled( state: &mut OpState, -) -> Result<(ResourceId, ResourceId), AnyError> { +) -> (ResourceId, ResourceId) { let (port1, port2) = create_entangled_message_port(); let port1_id = state.resource_table.add(MessagePortResource { @@ -122,7 +122,7 @@ pub fn op_message_port_create_entangled( cancel: CancelHandle::new(), }); - Ok((port1_id, port2_id)) + (port1_id, port2_id) } #[derive(Deserialize, Serialize)] diff --git a/ext/web/timers.rs b/ext/web/timers.rs index 670df3582..eee770719 100644 --- a/ext/web/timers.rs +++ b/ext/web/timers.rs @@ -28,7 +28,7 @@ pub type StartTime = Instant; // If the High precision flag is not set, the // nanoseconds are rounded on 2ms. #[op] -pub fn op_now<TP>(state: &mut OpState, _argument: ()) -> Result<f64, AnyError> +pub fn op_now<TP>(state: &mut OpState, _argument: ()) -> f64 where TP: TimersPermission + 'static, { @@ -44,9 +44,7 @@ where subsec_nanos -= subsec_nanos % reduced_time_precision; } - let result = (seconds * 1_000) as f64 + (subsec_nanos / 1_000_000.0); - - Ok(result) + (seconds * 1_000) as f64 + (subsec_nanos / 1_000_000.0) } pub struct TimerHandle(Rc<CancelHandle>); @@ -64,11 +62,10 @@ impl Resource for TimerHandle { /// Creates a [`TimerHandle`] resource that can be used to cancel invocations of /// [`op_sleep`]. #[op] -pub fn op_timer_handle(state: &mut OpState) -> Result<ResourceId, AnyError> { - let rid = state +pub fn op_timer_handle(state: &mut OpState) -> ResourceId { + state .resource_table - .add(TimerHandle(CancelHandle::new_rc())); - Ok(rid) + .add(TimerHandle(CancelHandle::new_rc())) } /// Waits asynchronously until either `millis` milliseconds have passed or the @@ -87,14 +84,10 @@ pub async fn op_sleep( } #[op] -pub fn op_sleep_sync<TP>( - state: &mut OpState, - millis: u64, -) -> Result<(), AnyError> +pub fn op_sleep_sync<TP>(state: &mut OpState, millis: u64) where TP: TimersPermission + 'static, { state.borrow::<TP>().check_unstable(state, "Deno.sleepSync"); std::thread::sleep(Duration::from_millis(millis)); - Ok(()) } |