Mercurial > crates > systemd-socket
diff src/error.rs @ 2:cabc4aafdd85
Added length check and a few tests
Systemd socket names must not exceed 255 chars, so this change satity
checks the limit.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Fri, 27 Nov 2020 10:21:07 +0100 |
parents | a65053246c29 |
children | 66c0e10c89fc |
line wrap: on
line diff
--- a/src/error.rs Fri Nov 27 10:07:35 2020 +0100 +++ b/src/error.rs Fri Nov 27 10:21:07 2020 +0100 @@ -20,7 +20,9 @@ #[error("failed to parse socket address")] SocketAddr(std::net::AddrParseError), #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] - InvalidCharacter { string: String, c: char, pos: usize, } + InvalidCharacter { string: String, c: char, pos: usize, }, + #[error("systemd socket name {string} is {len} characters long which is more than the limit 255")] + LongSocketName { string: String, len: usize, }, } /// Error that can occur during parsing of `SocketAddr` from a `OsStr`/`OsString`