From c3891cb4859c80dc7b0f721f7f8b9d5ef8157c13 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Tue, 23 May 2023 19:09:17 -0400 Subject: [PATCH] Add doc comment and example for `host` module --- src/host.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/host.rs b/src/host.rs index d510cfe..45e27f3 100644 --- a/src/host.rs +++ b/src/host.rs @@ -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}; #[derive(Clone, Debug, Default, PartialEq)]