summaryrefslogtreecommitdiff
path: root/ext/net
diff options
context:
space:
mode:
Diffstat (limited to 'ext/net')
-rw-r--r--ext/net/io.rs19
-rw-r--r--ext/net/ops.rs9
-rw-r--r--ext/net/ops_unix.rs5
3 files changed, 12 insertions, 21 deletions
diff --git a/ext/net/io.rs b/ext/net/io.rs
index f1403679a..6a93b8cf6 100644
--- a/ext/net/io.rs
+++ b/ext/net/io.rs
@@ -2,7 +2,6 @@
use crate::ops_tls as tls;
use deno_core::error::not_supported;
-use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::op_async;
use deno_core::AsyncMutFuture;
@@ -166,16 +165,15 @@ impl Resource for UnixStreamResource {
async fn op_read_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
- buf: Option<ZeroCopyBuf>,
+ mut buf: ZeroCopyBuf,
) -> Result<u32, AnyError> {
- let buf = &mut buf.ok_or_else(null_opbuf)?;
let resource = state.borrow().resource_table.get_any(rid)?;
let nread = if let Some(s) = resource.downcast_rc::<TcpStreamResource>() {
- s.read(buf).await?
+ s.read(&mut buf).await?
} else if let Some(s) = resource.downcast_rc::<TlsStreamResource>() {
- s.read(buf).await?
+ s.read(&mut buf).await?
} else if let Some(s) = resource.downcast_rc::<UnixStreamResource>() {
- s.read(buf).await?
+ s.read(&mut buf).await?
} else {
return Err(not_supported());
};
@@ -185,16 +183,15 @@ async fn op_read_async(
async fn op_write_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
- buf: Option<ZeroCopyBuf>,
+ buf: ZeroCopyBuf,
) -> Result<u32, AnyError> {
- let buf = &buf.ok_or_else(null_opbuf)?;
let resource = state.borrow().resource_table.get_any(rid)?;
let nwritten = if let Some(s) = resource.downcast_rc::<TcpStreamResource>() {
- s.write(buf).await?
+ s.write(&buf).await?
} else if let Some(s) = resource.downcast_rc::<TlsStreamResource>() {
- s.write(buf).await?
+ s.write(&buf).await?
} else if let Some(s) = resource.downcast_rc::<UnixStreamResource>() {
- s.write(buf).await?
+ s.write(&buf).await?
} else {
return Err(not_supported());
};
diff --git a/ext/net/ops.rs b/ext/net/ops.rs
index 52e513f71..7019a9b1f 100644
--- a/ext/net/ops.rs
+++ b/ext/net/ops.rs
@@ -7,7 +7,6 @@ use crate::NetPermissions;
use deno_core::error::bad_resource;
use deno_core::error::custom_error;
use deno_core::error::generic_error;
-use deno_core::error::null_opbuf;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op_async;
@@ -167,9 +166,8 @@ pub(crate) struct ReceiveArgs {
async fn receive_udp(
state: Rc<RefCell<OpState>>,
args: ReceiveArgs,
- zero_copy: Option<ZeroCopyBuf>,
+ zero_copy: ZeroCopyBuf,
) -> Result<OpPacket, AnyError> {
- let zero_copy = zero_copy.ok_or_else(null_opbuf)?;
let mut zero_copy = zero_copy.clone();
let rid = args.rid;
@@ -197,7 +195,7 @@ async fn receive_udp(
async fn op_datagram_receive(
state: Rc<RefCell<OpState>>,
args: ReceiveArgs,
- zero_copy: Option<ZeroCopyBuf>,
+ zero_copy: ZeroCopyBuf,
) -> Result<OpPacket, AnyError> {
match args.transport.as_str() {
"udp" => receive_udp(state, args, zero_copy).await,
@@ -218,12 +216,11 @@ struct SendArgs {
async fn op_datagram_send<NP>(
state: Rc<RefCell<OpState>>,
args: SendArgs,
- zero_copy: Option<ZeroCopyBuf>,
+ zero_copy: ZeroCopyBuf,
) -> Result<usize, AnyError>
where
NP: NetPermissions + 'static,
{
- let zero_copy = zero_copy.ok_or_else(null_opbuf)?;
let zero_copy = zero_copy.clone();
match args {
diff --git a/ext/net/ops_unix.rs b/ext/net/ops_unix.rs
index c39252fbf..20d085a5d 100644
--- a/ext/net/ops_unix.rs
+++ b/ext/net/ops_unix.rs
@@ -8,7 +8,6 @@ use crate::ops::OpPacket;
use crate::ops::ReceiveArgs;
use deno_core::error::bad_resource;
use deno_core::error::custom_error;
-use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::AsyncRefCell;
use deno_core::CancelHandle;
@@ -114,10 +113,8 @@ pub(crate) async fn accept_unix(
pub(crate) async fn receive_unix_packet(
state: Rc<RefCell<OpState>>,
args: ReceiveArgs,
- buf: Option<ZeroCopyBuf>,
+ mut buf: ZeroCopyBuf,
) -> Result<OpPacket, AnyError> {
- let mut buf = buf.ok_or_else(null_opbuf)?;
-
let rid = args.rid;
let resource = state