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.
Trait Implementations§
Source§impl Layer for FtpLayer
impl Layer for FtpLayer
Source§fn header_len(&self, buf: &[u8]) -> usize
fn header_len(&self, buf: &[u8]) -> usize
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for FtpLayer
impl LayerDispatch for FtpLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
_buf: &mut [u8],
_name: &str,
_value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, _buf: &mut [u8], _name: &str, _value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for FtpLayer
impl RefUnwindSafe for FtpLayer
impl Send for FtpLayer
impl Sync for FtpLayer
impl Unpin for FtpLayer
impl UnsafeUnpin for FtpLayer
impl UnwindSafe for FtpLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more