Function rpsl::parse_whois_response

source ·
pub fn parse_whois_response(
    response: &str
) -> Result<Vec<ObjectView<'_>>, Error<&str>>
Expand description

Parse a WHOIS server response into ObjectViews of the objects contained within.

Errors

Returns a Nom error if the input is not valid RPSL.

Examples

let whois_response = "
ASNumber:       32934
ASName:         FACEBOOK
ASHandle:       AS32934
RegDate:        2004-08-24
Updated:        2012-02-24
Comment:        Please send abuse reports to abuse@facebook.com
Ref:            https://rdap.arin.net/registry/autnum/32934


OrgName:        Facebook, Inc.
OrgId:          THEFA-3
Address:        1601 Willow Rd.
City:           Menlo Park
StateProv:      CA
PostalCode:     94025
Country:        US
RegDate:        2004-08-11
Updated:        2012-04-17
Ref:            https://rdap.arin.net/registry/entity/THEFA-3

";
let objects = parse_whois_response(whois_response)?;
assert_eq!(
    objects,
    vec![
            object! {
                "ASNumber": "32934";
                "ASName": "FACEBOOK";
                "ASHandle": "AS32934";
                "RegDate": "2004-08-24";
                "Updated": "2012-02-24";
                "Comment": "Please send abuse reports to abuse@facebook.com";
                "Ref": "https://rdap.arin.net/registry/autnum/32934";
            },
            object! {
                "OrgName": "Facebook, Inc.";
                "OrgId": "THEFA-3";
                "Address": "1601 Willow Rd.";
                "City": "Menlo Park";
                "StateProv": "CA";
                "PostalCode": "94025";
                "Country": "US";
                "RegDate": "2004-08-11";
                "Updated": "2012-04-17";
                "Ref": "https://rdap.arin.net/registry/entity/THEFA-3";
            }
        ]
);