pub struct MethodName(/* private fields */);Expand description
A method name, validated.
A newtype for the same reason TransportSpec is: a method name is a string
that has to be exact, and passing a raw &str around means the “did you
mean notifications/cancelled or notifications/canceled” check lives in
whoever happens to be comparing. Constructed from a literal or FromStr, so
the check is at the boundary.
Implementations§
Source§impl MethodName
impl MethodName
Sourcepub fn new(name: &str) -> Result<Self, MethodNameError>
pub fn new(name: &str) -> Result<Self, MethodNameError>
A method name, validated as non-empty and slash-separated.
§Errors
MethodNameError::Empty when the name is empty,
MethodNameError::NoSegment when it starts or ends with /, and
MethodNameError::Whitespace when a segment has surrounding space —
the last of which catches "tools/list " losing a race in string
concatenation.
Sourcepub fn is_notification(&self) -> bool
pub fn is_notification(&self) -> bool
Whether the name is a notification, which is the one naming convention the spec fixes across every revision.