pub struct Message {
pub tags: Tags,
pub source: Option<Source>,
pub command: String,
pub params: Vec<String>,
}Expand description
A parsed protocol line.
The types are owned rather than borrowed from the input. A borrowed Message<'a> would parse
faster, but every consumer of this crate reaches it across a language boundary that cannot carry
a Rust lifetime, so the copy has to happen somewhere and here is the only place it happens once.
Fields§
The tag section, empty when the line carried no @.
source: Option<Source>The source, when the line carried one.
command: StringThe command or three-digit numeric, as it arrived. Commands are case-insensitive on the wire,
so compare with Message::is rather than ==.
params: Vec<String>The parameters, with the trailing parameter last and its : removed.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
command: impl Into<String>,
params: impl IntoIterator<Item: Into<String>>,
) -> Self
pub fn new( command: impl Into<String>, params: impl IntoIterator<Item: Into<String>>, ) -> Self
Build a message with no tags and no source.
Sourcepub fn parse(line: &str) -> Result<Self, ParseError>
pub fn parse(line: &str) -> Result<Self, ParseError>
Parse one line. A trailing CRLF is optional and is ignored.
Sourcepub fn is(&self, command: &str) -> bool
pub fn is(&self, command: &str) -> bool
Compare the command case-insensitively, which is how the wire defines it.
Sourcepub fn param(&self, index: usize) -> Option<&str>
pub fn param(&self, index: usize) -> Option<&str>
The parameter at this position, if the message has one.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Message
impl StructuralPartialEq for Message
Source§impl TS for Message
impl TS for Message
Source§const DOCS: Option<&'static str>
const DOCS: Option<&'static str>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§type WithoutGenerics = Message
type WithoutGenerics = Message
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or ().
The only requirement for these dummy types is that EXPORT_TO must be None. Read moreSource§fn decl_concrete() -> String
fn decl_concrete() -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl() -> String
fn decl() -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline() -> String
fn inline() -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened() -> String
fn inline_flattened() -> String
This function will panic if the type cannot be flattened.
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<&'static Path>
fn output_path() -> Option<&'static Path>
T should be exported.The returned path does not include the base directory from
TS_RS_EXPORT_DIR. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
§fn dependencies() -> Vec<Dependency>where
Self: 'static,
fn dependencies() -> Vec<Dependency>where
Self: 'static,
§fn export() -> Result<(), ExportError>where
Self: 'static,
fn export() -> Result<(), ExportError>where
Self: 'static,
TS::export_all]. Read more§fn export_all() -> Result<(), ExportError>where
Self: 'static,
fn export_all() -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use [
TS::export]. Read more§fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use [
TS::export]. Read more§fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
§fn default_output_path() -> Option<PathBuf>
fn default_output_path() -> Option<PathBuf>
T should be exported. Read more