Make more network methods nothrow.
TCPConection properties and NetworkAddress.to(Address)String have been marked nothrow.
This commit is contained in:
parent
2ff37202c0
commit
96b798200c
|
@ -299,7 +299,7 @@ struct NetworkAddress {
|
||||||
/** Returns a string representation of the IP address
|
/** Returns a string representation of the IP address
|
||||||
*/
|
*/
|
||||||
string toAddressString()
|
string toAddressString()
|
||||||
const {
|
const nothrow {
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
auto ret = appender!string();
|
auto ret = appender!string();
|
||||||
ret.reserve(40);
|
ret.reserve(40);
|
||||||
|
@ -308,11 +308,13 @@ struct NetworkAddress {
|
||||||
}
|
}
|
||||||
/// ditto
|
/// ditto
|
||||||
void toAddressString(scope void delegate(const(char)[]) @safe sink)
|
void toAddressString(scope void delegate(const(char)[]) @safe sink)
|
||||||
const {
|
const nothrow {
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
import std.format : formattedWrite;
|
import std.format : formattedWrite;
|
||||||
ubyte[2] _dummy = void; // Workaround for DMD regression in master
|
ubyte[2] _dummy = void; // Workaround for DMD regression in master
|
||||||
|
|
||||||
|
scope (failure) assert(false);
|
||||||
|
|
||||||
switch (this.family) {
|
switch (this.family) {
|
||||||
default: assert(false, "toAddressString() called for invalid address family.");
|
default: assert(false, "toAddressString() called for invalid address family.");
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -333,7 +335,7 @@ struct NetworkAddress {
|
||||||
/** Returns a full string representation of the address, including the port number.
|
/** Returns a full string representation of the address, including the port number.
|
||||||
*/
|
*/
|
||||||
string toString()
|
string toString()
|
||||||
const {
|
const nothrow {
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
auto ret = appender!string();
|
auto ret = appender!string();
|
||||||
toString(str => ret.put(str));
|
toString(str => ret.put(str));
|
||||||
|
@ -341,8 +343,9 @@ struct NetworkAddress {
|
||||||
}
|
}
|
||||||
/// ditto
|
/// ditto
|
||||||
void toString(scope void delegate(const(char)[]) @safe sink)
|
void toString(scope void delegate(const(char)[]) @safe sink)
|
||||||
const {
|
const nothrow {
|
||||||
import std.format : formattedWrite;
|
import std.format : formattedWrite;
|
||||||
|
scope (failure) assert(false);
|
||||||
switch (this.family) {
|
switch (this.family) {
|
||||||
default: assert(false, "toString() called for invalid address family.");
|
default: assert(false, "toString() called for invalid address family.");
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -438,17 +441,17 @@ struct TCPConnection {
|
||||||
|
|
||||||
bool opCast(T)() const nothrow if (is(T == bool)) { return m_socket != StreamSocketFD.invalid; }
|
bool opCast(T)() const nothrow if (is(T == bool)) { return m_socket != StreamSocketFD.invalid; }
|
||||||
|
|
||||||
@property void tcpNoDelay(bool enabled) { eventDriver.sockets.setTCPNoDelay(m_socket, enabled); m_context.tcpNoDelay = enabled; }
|
@property void tcpNoDelay(bool enabled) nothrow { eventDriver.sockets.setTCPNoDelay(m_socket, enabled); m_context.tcpNoDelay = enabled; }
|
||||||
@property bool tcpNoDelay() const { return m_context.tcpNoDelay; }
|
@property bool tcpNoDelay() const nothrow { return m_context.tcpNoDelay; }
|
||||||
@property void keepAlive(bool enabled) { eventDriver.sockets.setKeepAlive(m_socket, enabled); m_context.keepAlive = enabled; }
|
@property void keepAlive(bool enabled) nothrow { eventDriver.sockets.setKeepAlive(m_socket, enabled); m_context.keepAlive = enabled; }
|
||||||
@property bool keepAlive() const { return m_context.keepAlive; }
|
@property bool keepAlive() const nothrow { return m_context.keepAlive; }
|
||||||
@property void readTimeout(Duration duration) { m_context.readTimeout = duration; }
|
@property void readTimeout(Duration duration) { m_context.readTimeout = duration; }
|
||||||
@property Duration readTimeout() const { return m_context.readTimeout; }
|
@property Duration readTimeout() const nothrow { return m_context.readTimeout; }
|
||||||
@property string peerAddress() const { return m_context.remoteAddress.toString(); }
|
@property string peerAddress() const nothrow { return m_context.remoteAddress.toString(); }
|
||||||
@property NetworkAddress localAddress() const { return m_context.localAddress; }
|
@property NetworkAddress localAddress() const nothrow { return m_context.localAddress; }
|
||||||
@property NetworkAddress remoteAddress() const { return m_context.remoteAddress; }
|
@property NetworkAddress remoteAddress() const nothrow { return m_context.remoteAddress; }
|
||||||
@property bool connected()
|
@property bool connected()
|
||||||
const {
|
const nothrow {
|
||||||
if (m_socket == StreamSocketFD.invalid) return false;
|
if (m_socket == StreamSocketFD.invalid) return false;
|
||||||
auto s = eventDriver.sockets.getConnectionState(m_socket);
|
auto s = eventDriver.sockets.getConnectionState(m_socket);
|
||||||
return s >= ConnectionState.connected && s < ConnectionState.activeClose;
|
return s >= ConnectionState.connected && s < ConnectionState.activeClose;
|
||||||
|
|
Loading…
Reference in a new issue