feat: enhance type definitions in io/socket

This commit is contained in:
Shunsuke Shibayama 2023-04-28 21:20:30 +09:00
parent ed2440dbfd
commit 443765a18b
3 changed files with 176 additions and 31 deletions

36
Cargo.lock generated
View file

@ -182,9 +182,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "libc"
version = "0.2.140"
version = "0.2.142"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
[[package]]
name = "lock_api"
@ -307,9 +307,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "proc-macro2"
version = "1.0.52"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
dependencies = [
"unicode-ident",
]
@ -334,9 +334,9 @@ dependencies = [
[[package]]
name = "rustc-demangle"
version = "0.1.21"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "ryu"
@ -352,18 +352,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.156"
version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4"
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.156"
version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
dependencies = [
"proc-macro2",
"quote",
@ -372,9 +372,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.94"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
dependencies = [
"itoa",
"ryu",
@ -383,9 +383,9 @@ dependencies = [
[[package]]
name = "serde_repr"
version = "0.1.11"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc"
checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
dependencies = [
"proc-macro2",
"quote",
@ -430,9 +430,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "syn"
version = "1.0.109"
version = "2.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
dependencies = [
"proc-macro2",
"quote",
@ -456,9 +456,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "unicode-bidi"
version = "0.3.11"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
[[package]]
name = "unicode-ident"

View file

@ -1,20 +1,102 @@
.DEFAULT_BUFFER_SIZE: {8192}
.StringIO!: ClassType
.StringIO! <: FileLike!
.StringIO!.
read!: (self: RefMut(.StringIO!), ) => Str
write!: (self: RefMut(.StringIO!), s: Str) => NoneType
getvalue!: (self: Ref(.StringIO!),) => Str
.IOBase!: ClassType
.IOBase!.
close!: (self: RefMut(.IOBase!),) => NoneType
closed: Bool
fileno: (self: Ref(.IOBase!),) -> Nat
flush!: (self: RefMut(.IOBase!),) => NoneType
isatty: (self: Ref(.IOBase!),) -> Bool
readable: (self: Ref(.IOBase!),) -> Bool
readline!: (self: RefMut(.IOBase!), size := Nat) => Str
readlines!: (self: RefMut(.IOBase!), hint := Nat) => [Str; _]
seek!: (self: RefMut(.IOBase!), offset: Nat, whence := Nat) => Nat
seekable: (self: Ref(.IOBase!),) -> Bool
tell!: (self: RefMut(.IOBase!),) => Nat
truncate!: (self: RefMut(.IOBase!), size := Nat) => Nat
writable: (self: Ref(.IOBase!),) -> Bool
writelines!: (self: RefMut(.IOBase!), lines: [Str; _]) => NoneType
.TextIOWrapper!: ClassType
.RawIOBase!: ClassType
.RawIOBase! <: .IOBase!
.RawIOBase!.
read!: (self: RefMut(.RawIOBase!), size := Nat) => Bytes
readall!: (self: RefMut(.RawIOBase!),) => Bytes
readinto!: (self: RefMut(.RawIOBase!), b: Bytes) => Nat
write!: (self: RefMut(.RawIOBase!), b: Bytes) => Nat
.BufferedIOBase!: ClassType
.BufferedIOBase! <: .IOBase!
.BufferedIOBase!.
raw: .RawIOBase!
detach!: (self: RefMut(.BufferedIOBase!),) => .RawIOBase!
read!: (self: RefMut(.BufferedIOBase!), size := Nat) => Bytes
read1!: (self: RefMut(.BufferedIOBase!), size := Nat) => Bytes
readinto!: (self: RefMut(.BufferedIOBase!), b: Bytes) => Nat
readinto1!: (self: RefMut(.BufferedIOBase!), b: Bytes) => Nat
write!: (self: RefMut(.BufferedIOBase!), b: Bytes) => Nat
.FileIO!: ClassType
.FileIO! <: .RawIOBase!
.FileIO!.
__call__: (path: PathLike, mode := Str, closefd := Bool, opener := NoneType) -> .FileIO!
mode: Str
name: Str
.BytesIO!: ClassType
.BytesIO! <: FileLike!
.BytesIO! <: .BufferedIOBase!
.BytesIO!.
read!: (self: RefMut(.BytesIO!), ) => Bytes
write!: (self: RefMut(.BytesIO!), b: Bytes) => NoneType
.newBytesIO = 'BytesIO': (bytes: Bytes,) -> .BytesIO!
__call__: (initial_bytes := Bytes) -> .BytesIO!
getvalue: (self: Ref(.BytesIO!),) -> Bytes
.BufferedReader!: ClassType
.BufferedReader! <: .BufferedIOBase!
.BufferedReader!.
__call__: (raw: .RawIOBase!, buffer_size := Nat) -> .BufferedReader!
peek!: (self: RefMut(.BufferedReader!), size := Nat) => Bytes
read!: (self: RefMut(.BufferedReader!), size := Nat) => Bytes
read1!: (self: RefMut(.BufferedReader!), size := Nat) => Bytes
.BufferedWriter!: ClassType
.BufferedWriter! <: .BufferedIOBase!
.BufferedWriter!.
__call__: (raw: .RawIOBase!, buffer_size := Nat) -> .BufferedWriter!
flush!: (self: RefMut(.BufferedWriter!),) => NoneType
write!: (self: RefMut(.BufferedWriter!), b: Bytes) => Nat
.BufferedRandom!: ClassType
.BufferedRandom! <: .BufferedReader!
.BufferedRWPair!: ClassType
.BufferedRWPair! <: .BufferedIOBase!
TextIOBase!: ClassType
TextIOBase! <: FileLike!
TextIOBase!.
encoding: Str
errors: Str
newlines: Str or [Str; _] or NoneType
buffer: .BufferedIOBase!
detach!: (self: RefMut(TextIOBase!),) => .BufferedIOBase!
read!: (self: RefMut(TextIOBase!), size := Nat) => Str
readline!: (self: RefMut(TextIOBase!), size := Nat) => Str
seek!: (self: RefMut(TextIOBase!), offset: Nat, whence := Nat) => Nat
tell!: (self: RefMut(TextIOBase!),) => Nat
write!: (self: RefMut(TextIOBase!), s: Str) => Nat
.TextIOWrapper!: ClassType
.TextIOWrapper! <: TextIOBase!
.TextIOWrapper!.
__call__: (buffer: .BufferedIOBase!, encoding := Str, errors := Str, newline := Str, line_buffering := Bool) -> .TextIOWrapper!
line_buffering: Bool
write_through: Bool
reconfigure!: (self: RefMut(.TextIOWrapper!), encoding := Str, errors := Str, newline := Str) => NoneType
.StringIO!: ClassType
.StringIO! <: TextIOBase!
.StringIO!.
__call__: (initial_value := Str, newline := Str) -> .StringIO!
getvalue: (self: Ref(.StringIO!),) -> Str
.open!: (file: PathLike, mode := Str, buffering := Nat, encoding := Str or NoneType) -> File!
.open_code!: (path: PathLike) -> File!

View file

@ -88,5 +88,68 @@
.SOL_TIPC: Nat
.SOL_UDP: Nat
.Socket!: ClassType
.Socket!.new: (family := Int, type := Int, proto := Int, fileno: Int or NoneType := NoneType) -> .Socket!
.Socket! = 'socket': ClassType
.Socket!.
new!: (family := Int, type := Int, proto := Int, fileno: Int or NoneType := NoneType) => .Socket!
__call__!: (family := Int, type := Int, proto := Int, fileno: Int or NoneType := NoneType) => .Socket!
accept!: (self: RefMut(.Socket!)) => (.Socket!, (Str, Int))
bind!: (self: RefMut(.Socket!), address: (Str, Int)) => NoneType
close!: (self: RefMut(.Socket!)) => NoneType
connect!: (self: RefMut(.Socket!), address: (Str, Int)) => NoneType
connect_ex!: (self: RefMut(.Socket!), address: (Str, Int)) => Int
detach!: (self: RefMut(.Socket!)) => Int
dup!: (self: RefMut(.Socket!)) => .Socket!
fileno!: (self: RefMut(.Socket!)) => Int
get_inheritable!: (self: RefMut(.Socket!)) => Bool
getpeername!: (self: RefMut(.Socket!)) => (Str, Int)
getsockname!: (self: RefMut(.Socket!)) => (Str, Int)
getsockopt!: (self: RefMut(.Socket!), level: Int, option: Int, buffersize: Int) => Str or Int
getblocking!: (self: RefMut(.Socket!)) => Bool
gettimeout!: (self: RefMut(.Socket!)) => Float or NoneType
listen!: (self: RefMut(.Socket!), backlog: Int) => NoneType
recv!: (self: RefMut(.Socket!), bufsize: Int, flags := Int) => Str
recvfrom!: (self: RefMut(.Socket!), bufsize: Int, flags := Int) => (Str, (Str, Int))
recvmsg!: (self: RefMut(.Socket!), bufsize: Int, ancbufsize := Int, flags := Int) => (Str, (Str, Int), Int)
recvmsg_into!: (self: RefMut(.Socket!), buffers: Iterable(Writable!), ancbufsize := Int, flags := Int) => (Str, (Str, Int), Int)
recvfrom_into!: (self: RefMut(.Socket!), buffer: Writable!, flags := Int) => (Str, (Str, Int))
recv_into!: (self: RefMut(.Socket!), buffer: Writable!, nbytes := Int, flags := Int) => Nat
send!: (self: RefMut(.Socket!), data: Bytes, flags := Int) => Int
sendall!: (self: RefMut(.Socket!), data: Bytes, flags := Int) => NoneType
sendto!: (self: RefMut(.Socket!), data: Bytes, address: (Str, Int), flags := Int) => Int
sendmsg!: (
self: RefMut(.Socket!),
buffers: Iterable(Bytes),
ancdata: Iterable(Bytes),
flags := Int,
address: (Str, Int) or NoneType := NoneType
) => Int
.socketpair!: (family := Int, type := Int, proto := Int, fileno: Int or NoneType := NoneType) => (.Socket!, .Socket!)
.create_connection!: (
address: (Str, Int),
timeout: Int or NoneType := NoneType,
source_address: (Str, Int) or NoneType := NoneType
) => .Socket!
.create_server!: (
address: (Str, Int),
family: Int or NoneType := NoneType,
backlog: Int or NoneType := NoneType,
reuse_port := Bool
) => .Socket!
.has_dualstack_ipv6: () -> Bool
.fromfd!: (fd: Int, family: Int, type: Int, proto: Int) => .Socket!
.close!: (fd: .Socket!) => NoneType
.getaddrinfo!: (
host: Str,
port: Int or NoneType,
family: Int or NoneType := NoneType,
type: Int or NoneType := NoneType,
proto: Int or NoneType := NoneType,
flags: Int or NoneType := NoneType,
) => (Int, Int, Int, Str, (Str, Int))
.gethostbyname!: (hostname: Str) => Str
.gethostbyname_ex!: (hostname: Str) => (Str, [Str; _], [Str; _])
.gethostname!: () => Str
.gethostbyaddr!: (ip: Str) => (Str, [Str; _], [Str; _])
.getnameinfo!: (sockaddr: (Str, Int), flags: Int or NoneType := NoneType) => (Str, Str)