Struct libtelnet_rs::Parser [−][src]
pub struct Parser {
pub options: CompatibilityTable,
// some fields omitted
}
Expand description
A telnet parser that handles the main parts of the protocol.
Fields
options: CompatibilityTable
Implementations
Create a default, empty Parser with an internal buffer capacity of 128 bytes.
Create an empty parser, setting the initial internal buffer capcity.
Create an parser, setting the initial internal buffer capacity and directly supplying a CompatibilityTable.
Create a parser, directly supplying a CompatibilityTable.
Uses the default initial buffer capacity of 128 bytes.
Get whether the remote end supports and is using linemode.
Escape IAC bytes in data that is to be transmitted and treated as a non-IAC sequence.
Example
[255, 1, 6, 2]
-> [255, 255, 1, 6, 2]
Reverse escaped IAC bytes for non-IAC sequences and data.
Example
[255, 255, 1, 6, 2]
-> [255, 1, 6, 2]
Negotiate an option.
Arguments
command
- A u8
representing the telnet command code to be negotiated with. Example: WILL (251), WONT (252), DO (253), DONT (254)
option
- A u8
representing the telnet option code that is being negotiated.
Returns
events::TelnetEvents::DataSend
- A DataSend event to be processed.
Usage
This and other methods meant for sending data to the remote end will generate a TelnetEvents::Send(DataEvent)
event.
These Send events contain a buffer that should be sent directly to the remote end, as it will have already been encoded properly.
Indicate to the other side that you are able and wanting to utilize an option.
Arguments
option
- A u8
representing the telnet option code that you want to enable locally.
Returns
Option<events::TelnetEvents::DataSend>
- The DataSend event to be processed, or None if not supported.
Notes
This method will do nothing if the option is not “supported” locally via the CompatibilityTable
.
Indicate to the other side that you would like them to utilize an option.
Arguments
option
- A u8
representing the telnet option code that you want to enable remotely.
Returns
Option<events::TelnetEvents::DataSend>
- A DataSend event to be processed, or None if the option is not supported or already enabled.
Notes
This method will do nothing if the option is not “supported” remotely via the CompatibilityTable
.
Indicate to the other side that you would like them to stop utilizing an option.
Arguments
option
- A u8
representing the telnet option code that you want to disable remotely.
Returns
Option<events::TelnetEvents::DataSend>
- A DataSend event to be processed, or None if the option is already disabled.
pub fn subnegotiation<T>(&mut self, option: u8, data: T) -> Option<TelnetEvents> where
Bytes: From<T>,
pub fn subnegotiation<T>(&mut self, option: u8, data: T) -> Option<TelnetEvents> where
Bytes: From<T>,
Send a subnegotiation for a locally supported option.
Arguments
option
- A u8
representing the telnet option code for the negotiation.
data
- A Bytes
containing the data to be sent in the subnegotiation. This data will have all IAC (255) byte values escaped.
Returns
Option<events::TelnetEvents::DataSend>
- A DataSend event to be processed, or None if the option is not supported or is currently disabled.
Notes
This method will do nothing if the option is not “supported” locally via the CompatibilityTable
.
Send a subnegotiation for a locally supported option, using a string instead of raw byte values.
Arguments
option
- A u8
representing the telnet option code for the negotiation.
text
- A &str
representing the text to be sent in the subnegotation. This data will have all IAC (255) byte values escaped.
Returns
Option<events::TelnetEvents::DataSend>
- A DataSend event to be processed, or None if the option is not supported or is currently disabled.
Notes
This method will do nothing if the option is not “supported” locally via the CompatibilityTable
.