Skip to main content

zone_for_host

Function zone_for_host 

Source
pub fn zone_for_host<'a>(zones: &'a [Zone], host: &str) -> Option<&'a Zone>
Expand description

The zone of zones that host is in: the longest zone name equal to the host or a suffix of it at a label boundary. Case and a trailing dot do not matter.

ยงExamples

use dinio_sdk::models::Zone;
use dinio_sdk::ops::zone_for_host;

let zones = [zone("example.com"), zone("shop.example.com")];
assert_eq!(zone_for_host(&zones, "go.example.com").unwrap().name, "example.com");
assert_eq!(zone_for_host(&zones, "Www.Shop.Example.com.").unwrap().name, "shop.example.com");
assert!(zone_for_host(&zones, "badexample.com").is_none());