rbs 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,132 @@
1
+ # UNIXSocket represents a UNIX domain stream client socket.
2
+ class UNIXSocket < BasicSocket
3
+ # Creates a pair of sockets connected to each other.
4
+ #
5
+ # *socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
6
+ #
7
+ # *protocol* should be a protocol defined in the domain. 0 is default protocol
8
+ # for the domain.
9
+ #
10
+ # s1, s2 = UNIXSocket.pair
11
+ # s1.send "a", 0
12
+ # s1.send "b", 0
13
+ # p s2.recv(10) #=> "ab"
14
+ #
15
+ def self.pair: (?Symbol socktype, ?Integer protocol) -> [instance, instance]
16
+
17
+ # Creates a pair of sockets connected to each other.
18
+ #
19
+ # *socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
20
+ #
21
+ # *protocol* should be a protocol defined in the domain. 0 is default protocol
22
+ # for the domain.
23
+ #
24
+ # s1, s2 = UNIXSocket.pair
25
+ # s1.send "a", 0
26
+ # s1.send "b", 0
27
+ # p s2.recv(10) #=> "ab"
28
+ #
29
+ def self.socketpair: (?Symbol socktype, ?Integer protocol) -> [instance, instance]
30
+
31
+ public
32
+
33
+ # Returns the local address as an array which contains address_family and
34
+ # unix_path.
35
+ #
36
+ # Example
37
+ # serv = UNIXServer.new("/tmp/sock")
38
+ # p serv.addr #=> ["AF_UNIX", "/tmp/sock"]
39
+ #
40
+ def addr: () -> [String, String]
41
+
42
+ # Returns the path of the local address of unixsocket.
43
+ #
44
+ # s = UNIXServer.new("/tmp/sock")
45
+ # p s.path #=> "/tmp/sock"
46
+ #
47
+ def path: () -> String
48
+
49
+ # Returns the remote address as an array which contains address_family and
50
+ # unix_path.
51
+ #
52
+ # Example
53
+ # serv = UNIXServer.new("/tmp/sock")
54
+ # c = UNIXSocket.new("/tmp/sock")
55
+ # p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"]
56
+ #
57
+ def peeraddr: () -> [String, String]
58
+
59
+ # Example
60
+ #
61
+ # UNIXServer.open("/tmp/sock") {|serv|
62
+ # UNIXSocket.open("/tmp/sock") {|c|
63
+ # s = serv.accept
64
+ #
65
+ # c.send_io STDOUT
66
+ # stdout = s.recv_io
67
+ #
68
+ # p STDOUT.fileno #=> 1
69
+ # p stdout.fileno #=> 7
70
+ #
71
+ # stdout.puts "hello" # outputs "hello\n" to standard output.
72
+ # }
73
+ # }
74
+ #
75
+ # *klass* will determine the class of *io* returned (using the IO.for_fd
76
+ # singleton method or similar). If *klass* is `nil`, an integer file descriptor
77
+ # is returned.
78
+ #
79
+ # *mode* is the same as the argument passed to IO.for_fd
80
+ #
81
+ def recv_io: (?singleton(BasicSocket), ?String mode) -> BasicSocket
82
+
83
+ # Receives a message via *unixsocket*.
84
+ #
85
+ # *maxlen* is the maximum number of bytes to receive.
86
+ #
87
+ # *flags* should be a bitwise OR of Socket::MSG_* constants.
88
+ #
89
+ # *outbuf* will contain only the received data after the method call even if it
90
+ # is not empty at the beginning.
91
+ #
92
+ # s1 = Socket.new(:UNIX, :DGRAM, 0)
93
+ # s1_ai = Addrinfo.unix("/tmp/sock1")
94
+ # s1.bind(s1_ai)
95
+ #
96
+ # s2 = Socket.new(:UNIX, :DGRAM, 0)
97
+ # s2_ai = Addrinfo.unix("/tmp/sock2")
98
+ # s2.bind(s2_ai)
99
+ # s3 = UNIXSocket.for_fd(s2.fileno)
100
+ #
101
+ # s1.send "a", 0, s2_ai
102
+ # p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]]
103
+ #
104
+ def recvfrom: (Integer maxlen, ?Integer flags, ?String outbuf) -> [String, [String, String]]
105
+
106
+ # Sends *io* as file descriptor passing.
107
+ #
108
+ # s1, s2 = UNIXSocket.pair
109
+ #
110
+ # s1.send_io STDOUT
111
+ # stdout = s2.recv_io
112
+ #
113
+ # p STDOUT.fileno #=> 1
114
+ # p stdout.fileno #=> 6
115
+ #
116
+ # stdout.puts "hello" # outputs "hello\n" to standard output.
117
+ #
118
+ # *io* may be any kind of IO object or integer file descriptor.
119
+ #
120
+ def send_io: (BasicSocket | Integer) -> void
121
+
122
+ private
123
+
124
+ # Creates a new UNIX client socket connected to *path*.
125
+ #
126
+ # require 'socket'
127
+ #
128
+ # s = UNIXSocket.new("/tmp/sock")
129
+ # s.send "hello", 0
130
+ #
131
+ def initialize: (String path) -> untyped
132
+ end
@@ -54,4 +54,9 @@ module Timeout
54
54
  def self?.timeout: [T] (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> T } -> T
55
55
  end
56
56
 
57
+ # Raised by Timeout.timeout when the block times out.
58
+ class Timeout::Error < RuntimeError
59
+ attr_reader thread: Thread?
60
+ end
61
+
57
62
  Timeout::VERSION: String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-26 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -86,6 +86,7 @@ files:
86
86
  - core/unbound_method.rbs
87
87
  - core/warning.rbs
88
88
  - docs/CONTRIBUTING.md
89
+ - docs/rbs_by_example.md
89
90
  - docs/repo.md
90
91
  - docs/sigs.md
91
92
  - docs/stdlib.md
@@ -213,12 +214,15 @@ files:
213
214
  - stdlib/logger/0/severity.rbs
214
215
  - stdlib/monitor/0/monitor.rbs
215
216
  - stdlib/mutex_m/0/mutex_m.rbs
217
+ - stdlib/net-http/0/net-http.rbs
218
+ - stdlib/optparse/0/optparse.rbs
216
219
  - stdlib/pathname/0/pathname.rbs
217
220
  - stdlib/prettyprint/0/prettyprint.rbs
218
221
  - stdlib/prime/0/integer-extension.rbs
219
222
  - stdlib/prime/0/prime.rbs
220
223
  - stdlib/pstore/0/pstore.rbs
221
224
  - stdlib/pty/0/pty.rbs
225
+ - stdlib/resolv/0/resolv.rbs
222
226
  - stdlib/rubygems/0/basic_specification.rbs
223
227
  - stdlib/rubygems/0/config_file.rbs
224
228
  - stdlib/rubygems/0/dependency_installer.rbs
@@ -237,6 +241,15 @@ files:
237
241
  - stdlib/set/0/set.rbs
238
242
  - stdlib/shellwords/0/shellwords.rbs
239
243
  - stdlib/singleton/0/singleton.rbs
244
+ - stdlib/socket/0/addrinfo.rbs
245
+ - stdlib/socket/0/basic_socket.rbs
246
+ - stdlib/socket/0/ip_socket.rbs
247
+ - stdlib/socket/0/socket.rbs
248
+ - stdlib/socket/0/tcp_server.rbs
249
+ - stdlib/socket/0/tcp_socket.rbs
250
+ - stdlib/socket/0/udp_socket.rbs
251
+ - stdlib/socket/0/unix_server.rbs
252
+ - stdlib/socket/0/unix_socket.rbs
240
253
  - stdlib/strscan/0/string_scanner.rbs
241
254
  - stdlib/time/0/time.rbs
242
255
  - stdlib/timeout/0/timeout.rbs
@@ -281,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
294
  - !ruby/object:Gem::Version
282
295
  version: '0'
283
296
  requirements: []
284
- rubygems_version: 3.2.15
297
+ rubygems_version: 3.2.3
285
298
  signing_key:
286
299
  specification_version: 4
287
300
  summary: Type signature for Ruby.