Compare commits
1 Commits
ad61be277b
...
77e09436a9
Author | SHA1 | Date | |
---|---|---|---|
|
77e09436a9 |
@ -39,7 +39,7 @@ impl FromStr for PortLocation {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
/// use brocade::port::PortLocation;
|
/// use harmony_types::switch::PortLocation;
|
||||||
///
|
///
|
||||||
/// assert_eq!(PortLocation::from_str("1/1/1").unwrap(), PortLocation(1, 1, 1));
|
/// assert_eq!(PortLocation::from_str("1/1/1").unwrap(), PortLocation(1, 1, 1));
|
||||||
/// assert_eq!(PortLocation::from_str("12/5/48").unwrap(), PortLocation(12, 5, 48));
|
/// assert_eq!(PortLocation::from_str("12/5/48").unwrap(), PortLocation(12, 5, 48));
|
||||||
@ -64,8 +64,8 @@ impl FromStr for PortLocation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a Brocade Port configuration input, which can be a single port, a sequential
|
/// Represents a Port configuration input, which can be a single port, a sequential range,
|
||||||
/// range, or an explicit set defined by endpoints.
|
/// or an explicit set defined by endpoints.
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||||
pub enum PortDeclaration {
|
pub enum PortDeclaration {
|
||||||
/// A single switch port defined by its location. Example: `PortDeclaration::Single(1/1/1)`
|
/// A single switch port defined by its location. Example: `PortDeclaration::Single(1/1/1)`
|
||||||
@ -82,7 +82,7 @@ pub enum PortDeclaration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PortDeclaration {
|
impl PortDeclaration {
|
||||||
/// Parses a Brocade port configuration string into a structured `PortDeclaration` enum.
|
/// Parses a port configuration string into a structured `PortDeclaration` enum.
|
||||||
///
|
///
|
||||||
/// This function performs only basic format and numerical parsing, assuming the input
|
/// This function performs only basic format and numerical parsing, assuming the input
|
||||||
/// strings (e.g., from `show` commands) are semantically valid and logically ordered.
|
/// strings (e.g., from `show` commands) are semantically valid and logically ordered.
|
||||||
@ -101,7 +101,7 @@ impl PortDeclaration {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use brocade::port::{PortDeclaration, PortLocation};
|
/// use harmony_types::switch::{PortDeclaration, PortLocation};
|
||||||
///
|
///
|
||||||
/// // Single Port
|
/// // Single Port
|
||||||
/// assert_eq!(PortDeclaration::parse("3/2/15").unwrap(), PortDeclaration::Single(PortLocation(3, 2, 15)));
|
/// assert_eq!(PortDeclaration::parse("3/2/15").unwrap(), PortDeclaration::Single(PortLocation(3, 2, 15)));
|
||||||
@ -150,7 +150,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_single_port_location_invalid() {
|
fn test_parse_port_location_invalid() {
|
||||||
assert!(PortLocation::from_str("1/1").is_err());
|
assert!(PortLocation::from_str("1/1").is_err());
|
||||||
assert!(PortLocation::from_str("1/A/1").is_err());
|
assert!(PortLocation::from_str("1/A/1").is_err());
|
||||||
assert!(PortLocation::from_str("1/1/256").is_err());
|
assert!(PortLocation::from_str("1/1/256").is_err());
|
||||||
|
Loading…
Reference in New Issue
Block a user