aboutsummaryrefslogtreecommitdiff
path: root/source/tanya/async/transport.d
blob: 8191678b4ff2bcc34919761887dee87249628deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 * Copyright: Eugene Wissner 2016.
 * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
 *                  Mozilla Public License, v. 2.0).
 * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
 */
module tanya.async.transport;

import tanya.network.socket;

/**
 * Base transport interface.
 */
interface Transport
{
}

/**
 * Interface for read-only transports.
 */
interface ReadTransport : Transport
{
}

/**
 * Interface for write-only transports.
 */
interface WriteTransport : Transport
{
	/**
	 * Write some data to the transport.
	 *
	 * Params:
	 * 	data = Data to send.
	 */
	void write(ubyte[] data);
}

/**
 * Represents a bidirectional transport.
 */
interface DuplexTransport : ReadTransport, WriteTransport
{
}

/**
 * Represents a socket transport.
 */
interface SocketTransport : Transport
{
	@property inout(Socket) socket() inout pure nothrow @safe @nogc;
}

/**
 * Represents a connection-oriented socket transport.
 */
package interface StreamTransport : DuplexTransport, SocketTransport
{
}