mirror of https://github.com/vacp2p/nim-libp2p.git
remove close from read/write methods
This commit is contained in:
parent
1b4876d26d
commit
71640da8f2
|
@ -86,30 +86,18 @@ method readExactly*(s: Connection,
|
||||||
pbytes: pointer,
|
pbytes: pointer,
|
||||||
nbytes: int):
|
nbytes: int):
|
||||||
Future[void] {.async, gcsafe.} =
|
Future[void] {.async, gcsafe.} =
|
||||||
try:
|
await s.stream.readExactly(pbytes, nbytes)
|
||||||
await s.stream.readExactly(pbytes, nbytes)
|
|
||||||
except CatchableError as exc:
|
|
||||||
await s.close()
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
method readOnce*(s: Connection,
|
method readOnce*(s: Connection,
|
||||||
pbytes: pointer,
|
pbytes: pointer,
|
||||||
nbytes: int):
|
nbytes: int):
|
||||||
Future[int] {.async, gcsafe.} =
|
Future[int] {.async, gcsafe.} =
|
||||||
try:
|
result = await s.stream.readOnce(pbytes, nbytes)
|
||||||
result = await s.stream.readOnce(pbytes, nbytes)
|
|
||||||
except CatchableError as exc:
|
|
||||||
await s.close()
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
method write*(s: Connection,
|
method write*(s: Connection,
|
||||||
msg: seq[byte]):
|
msg: seq[byte]):
|
||||||
Future[void] {.async, gcsafe.} =
|
Future[void] {.async, gcsafe.} =
|
||||||
try:
|
await s.stream.write(msg)
|
||||||
await s.stream.write(msg)
|
|
||||||
except CatchableError as exc:
|
|
||||||
await s.close()
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
method atEof*(s: Connection): bool {.inline.} =
|
method atEof*(s: Connection): bool {.inline.} =
|
||||||
if isNil(s.stream):
|
if isNil(s.stream):
|
||||||
|
|
Loading…
Reference in New Issue