Add doc comment and example for host module

This commit is contained in:
Nathan Fisher 2023-05-23 19:09:17 -04:00
parent 7bbdb1381d
commit c3891cb485

View file

@ -1,3 +1,16 @@
//! This module contains a data structure representing dns
//! hosts which can be readily parsed from or converted to strings.
//! # Examples
//! Parse a host from a given string
//! ```
//! use dory::host::Host;
//!
//! let host_str = "misfin.example.com";
//! let host: Host = host_str.parse().unwrap();
//! assert_eq!(host.subdomain.unwrap().as_str(), "misfin");
//! assert_eq!(host.domain.as_str(), "example");
//! assert_eq!(host.tld.as_str(), "com");
//! ```
use std::{fmt, str::FromStr}; use std::{fmt, str::FromStr};
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]