Mercurial > crates > systemd-socket
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:ef8bf41097ac | 2:cabc4aafdd85 |
---|---|
18 #[derive(Debug, Error)] | 18 #[derive(Debug, Error)] |
19 pub(crate) enum ParseErrorInner { | 19 pub(crate) enum ParseErrorInner { |
20 #[error("failed to parse socket address")] | 20 #[error("failed to parse socket address")] |
21 SocketAddr(std::net::AddrParseError), | 21 SocketAddr(std::net::AddrParseError), |
22 #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] | 22 #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] |
23 InvalidCharacter { string: String, c: char, pos: usize, } | 23 InvalidCharacter { string: String, c: char, pos: usize, }, |
24 #[error("systemd socket name {string} is {len} characters long which is more than the limit 255")] | |
25 LongSocketName { string: String, len: usize, }, | |
24 } | 26 } |
25 | 27 |
26 /// Error that can occur during parsing of `SocketAddr` from a `OsStr`/`OsString` | 28 /// Error that can occur during parsing of `SocketAddr` from a `OsStr`/`OsString` |
27 /// | 29 /// |
28 /// As opposed to parsing from `&str` or `String`, parsing from `OsStr` can fail due to one more | 30 /// As opposed to parsing from `&str` or `String`, parsing from `OsStr` can fail due to one more |