Skip to main content

Module builder

Module builder 

Source
Expand description

Convenience helpers for assembling firewall objects in “builder” style.

This module targets interactive or prototyping flows where developers want to express object definitions with as little boilerplate as possible. Helper functions turn dotted notation such as address("app1", "192.0.2.10") or service::tcp(443) into strongly typed objects that can be inserted into an ObjectStore.

use firewall_objects::builder::{address, service, service_group};
use firewall_objects::objects::ObjectStore;

let mut store = ObjectStore::new();

for entry in [
    address("server1", "192.168.50.10").unwrap(),
    address("Public DMZ", "10.10.105.0/24").unwrap(),
] {
    store.add(entry).unwrap();
}

let allowed_services = service_group("allowed services")
    .unwrap()
    .with_service(service::tcp(443))
    .unwrap()
    .with_service(service::udp(53))
    .unwrap()
    .build()
    .unwrap();

store.add(allowed_services).unwrap();
assert!(store.network("server1").is_ok());
assert!(store.service_group("allowed services").is_ok());

Modules§

service
Convenience namespace for transport builders: service::tcp(443) or service::parse("udp/53").

Structs§

ApplicationBuilder
Builder for application objects with minimal ceremony.
NetworkGroupBuilder
Builder helper for adding multiple network objects into the same group.
ServiceGroupBuilder
Builder helper for constructing service groups through chained calls.

Enums§

BuilderEntry
Unified wrapper returned by the builders so ObjectStore::add can accept any object or builder directly.

Traits§

IntoNetworkObj
Network helper trait implemented for both raw objects and builder entries.
IntoServiceObj
Service helper trait implemented for both raw objects and builder entries.

Functions§

address
Helper that builds a NetworkObj from a human-friendly input. The name is optional—pass an empty string to default to the normalized value.
application
Begin composing an application object.
network_group
Start a network group builder with the provided name.
service_group
Start a service group builder with the provided name.