pub struct FtpLayer {
pub index: LayerIndex,
}Expand description
A zero-copy view into an FTP layer within a packet buffer.
FTP is text-based, so all field access involves parsing ASCII text from the buffer slice on demand.
Fields§
§index: LayerIndexImplementations§
Source§impl FtpLayer
impl FtpLayer
pub fn new(index: LayerIndex) -> Self
pub fn at_start(len: usize) -> Self
Sourcepub fn message_kind(&self, buf: &[u8]) -> FtpMessageKind
pub fn message_kind(&self, buf: &[u8]) -> FtpMessageKind
Determine if this message is a reply (starts with 3-digit code) or command.
Sourcepub fn command(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn command(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the FTP command verb (for client messages).
Returns Err if this is a server reply, not a command.
§Errors
Returns FieldError::InvalidValue if the payload is not valid UTF-8.
Sourcepub fn args(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn args(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the command arguments (everything after the verb on the first line).
§Errors
Returns FieldError::InvalidValue if the payload is not valid UTF-8.
Sourcepub fn reply_code(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn reply_code(&self, buf: &[u8]) -> Result<u16, FieldError>
Returns the 3-digit reply code (for server replies).
§Errors
Returns FieldError::BufferTooShort if fewer than 3 bytes are available,
or FieldError::InvalidValue if the first 3 bytes are not ASCII digits.
Sourcepub fn reply_text(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn reply_text(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the reply text (text following the code, stripped of CR/LF).
§Errors
Returns FieldError::InvalidValue if the payload is not valid UTF-8 or
does not begin with a valid 3-digit reply code.
Sourcepub fn is_response(&self, buf: &[u8]) -> bool
pub fn is_response(&self, buf: &[u8]) -> bool
Returns true if this is a server reply (starts with a 3-digit code).
Sourcepub fn is_multiline(&self, buf: &[u8]) -> bool
pub fn is_multiline(&self, buf: &[u8]) -> bool
Returns true if this is a multi-line reply (code followed by -).
Sourcepub fn raw(&self, buf: &[u8]) -> String
pub fn raw(&self, buf: &[u8]) -> String
Returns the raw payload as a UTF-8 string (best effort).
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field by name.