From 746832384a036dc159d3bd559c53d1594e7175c4 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 5 Sep 2022 13:08:52 +0200 Subject: [PATCH] `Option` -> `Opt` (#307) --- chronos/apps/http/httpserver.nim | 26 +++++++++++++------------- chronos/asyncfutures2.nim | 2 +- chronos/asyncloop.nim | 2 +- chronos/streams/boundstream.nim | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/chronos/apps/http/httpserver.nim b/chronos/apps/http/httpserver.nim index 6adfb94..6adc4f0 100644 --- a/chronos/apps/http/httpserver.nim +++ b/chronos/apps/http/httpserver.nim @@ -6,13 +6,13 @@ # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) -import std/[tables, options, uri, strutils] +import std/[tables, uri, strutils] import stew/[results, base10], httputils import ../../asyncloop, ../../asyncsync import ../../streams/[asyncstream, boundstream, chunkstream] import httptable, httpcommon, multipart export asyncloop, asyncsync, httptable, httpcommon, httputils, multipart, - asyncstream, boundstream, chunkstream, uri, tables, options, results + asyncstream, boundstream, chunkstream, uri, tables, results type HttpServerFlags* {.pure.} = enum @@ -88,7 +88,7 @@ type state*: HttpState headers*: HttpTable query*: HttpTable - postTable: Option[HttpTable] + postTable: Opt[HttpTable] rawPath*: string uri*: Uri scheme*: string @@ -98,9 +98,9 @@ type transferEncoding*: set[TransferEncodingFlags] requestFlags*: set[HttpRequestFlags] contentLength: int - contentTypeData*: Option[ContentTypeData] + contentTypeData*: Opt[ContentTypeData] connection*: HttpConnectionRef - response*: Option[HttpResponseRef] + response*: Opt[HttpResponseRef] HttpRequestRef* = ref HttpRequest @@ -211,7 +211,7 @@ proc getResponse*(req: HttpRequestRef): HttpResponseRef {.raises: [Defect].} = else: {} ) - req.response = some(resp) + req.response = Opt.some(resp) resp else: req.response.get() @@ -351,7 +351,7 @@ proc prepareRequest(conn: HttpConnectionRef, request.requestFlags.incl(HttpRequestFlags.UrlencodedForm) elif contentType == MultipartContentType: request.requestFlags.incl(HttpRequestFlags.MultipartForm) - request.contentTypeData = some(contentType) + request.contentTypeData = Opt.some(contentType) if ExpectHeader in request.headers: let expectHeader = request.headers.getString(ExpectHeader) @@ -755,18 +755,18 @@ proc processLoop(server: HttpServerRef, transp: StreamTransport, break breakLoop = false - var lastErrorCode: Option[HttpCode] + var lastErrorCode: Opt[HttpCode] try: resp = await conn.server.processCallback(arg) except CancelledError: breakLoop = true except HttpCriticalError as exc: - lastErrorCode = some(exc.code) + lastErrorCode = Opt.some(exc.code) except HttpRecoverableError as exc: - lastErrorCode = some(exc.code) + lastErrorCode = Opt.some(exc.code) except CatchableError: - lastErrorCode = some(Http503) + lastErrorCode = Opt.some(Http503) if breakLoop: break @@ -983,7 +983,7 @@ proc post*(req: HttpRequestRef): Future[HttpTable] {.async.} = copyMem(addr strbody[0], addr body[0], len(body)) for key, value in queryParams(strbody, queryFlags): table.add(key, value) - req.postTable = some(table) + req.postTable = Opt.some(table) return table elif MultipartForm in req.requestFlags: var table = HttpTable.init() @@ -1029,7 +1029,7 @@ proc post*(req: HttpRequestRef): Future[HttpTable] {.async.} = await mpreader.closeWait() raise exc await mpreader.closeWait() - req.postTable = some(table) + req.postTable = Opt.some(table) return table else: if HttpRequestFlags.BoundBody in req.requestFlags: diff --git a/chronos/asyncfutures2.nim b/chronos/asyncfutures2.nim index b873292..98e85c3 100644 --- a/chronos/asyncfutures2.nim +++ b/chronos/asyncfutures2.nim @@ -8,7 +8,7 @@ # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) -import std/[os, tables, strutils, heapqueue, options, deques, sequtils] +import std/[os, tables, strutils, heapqueue, deques, sequtils] import stew/base10 import ./srcloc export srcloc diff --git a/chronos/asyncloop.nim b/chronos/asyncloop.nim index 8ef3753..131b318 100644 --- a/chronos/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -13,7 +13,7 @@ when (NimMajor, NimMinor) < (1, 4): else: {.push raises: [].} -import std/[os, tables, strutils, heapqueue, lists, options, nativesockets, net, +import std/[os, tables, strutils, heapqueue, lists, nativesockets, net, deques] import ./timer diff --git a/chronos/streams/boundstream.nim b/chronos/streams/boundstream.nim index 5c4299a..73321eb 100644 --- a/chronos/streams/boundstream.nim +++ b/chronos/streams/boundstream.nim @@ -14,7 +14,7 @@ ## ## For stream writing it means that you should write exactly bounded size ## of bytes. -import std/options +import stew/results import ../asyncloop, ../timer import asyncstream, ../transports/stream, ../transports/common export asyncloop, asyncstream, stream, timer, common @@ -24,7 +24,7 @@ type Equal, LessOrEqual BoundedStreamReader* = ref object of AsyncStreamReader - boundSize: Option[uint64] + boundSize: Opt[uint64] boundary: seq[byte] offset: uint64 cmpop: BoundCmp @@ -288,7 +288,7 @@ proc init*[T](child: BoundedStreamReader, rsource: AsyncStreamReader, comparison = BoundCmp.Equal, bufferSize = BoundedBufferSize, udata: ref T) = doAssert(len(boundary) > 0, BoundarySizeDefectMessage) - child.boundSize = some(boundSize) + child.boundSize = Opt.some(boundSize) child.boundary = @boundary child.cmpop = comparison init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize, @@ -297,7 +297,7 @@ proc init*[T](child: BoundedStreamReader, rsource: AsyncStreamReader, proc init*(child: BoundedStreamReader, rsource: AsyncStreamReader, boundSize: uint64, comparison = BoundCmp.Equal, bufferSize = BoundedBufferSize) = - child.boundSize = some(boundSize) + child.boundSize = Opt.some(boundSize) child.cmpop = comparison init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize) @@ -313,7 +313,7 @@ proc init*(child: BoundedStreamReader, rsource: AsyncStreamReader, boundSize: uint64, boundary: openArray[byte], comparison = BoundCmp.Equal, bufferSize = BoundedBufferSize) = doAssert(len(boundary) > 0, BoundarySizeDefectMessage) - child.boundSize = some(boundSize) + child.boundSize = Opt.some(boundSize) child.boundary = @boundary child.cmpop = comparison init(AsyncStreamReader(child), rsource, boundedReadLoop, bufferSize)