Implement the NetworkConfigBuilder functionality to ensure it correctly validates and constructs a NetworkConfig. The specific requirements for the implementation are as follows:
Bind Multiaddress Validation:
The bind multiaddress must consist of exactly two protocols:
The first protocol must be either Ip4, Ip6, or Dns.
The second protocol must be Tcp.
If the first protocol is Dns, it should resolve to an Ip4 or Ip6 address.
Reconnect Interval:
The reconnect interval must default to 30 seconds but should be configurable.
Any value provided must be at least 1.
Maximum Peers:
Allow setting the maximum number of unknown peers and discovered peers, with default values of 4 each.
Add Static Peers:
Ensure that a static peer can be added, but the implementation must check for and prevent duplicate peers based on their PeerId.
Error Handling:
Return appropriate error types from the Error enum as defined in the code when criteria are not met (e.g., underspecified, overspecified multiaddress).
In-Memory Configuration:
Create an InMemoryNetworkConfigBuilder that only accepts /memory multiaddresses, and implement a corresponding method to build this configuration.
Finish Method:
Implement the finish method of NetworkConfigBuilder to return a valid NetworkConfig object, initializing it with defaults where necessary.
Place the implemented code in the /app/ directory under a file named network_config.rs. Ensure that the implemented functionality aligns with the specifications from the provided test cases.