tatami 0.1.1

A library for creating satellites and interacting with Tatami protocols.
Documentation
use libp2p::identity::Keypair;

#[derive(Clone)]
/// Configuration for the Satellite
/// For ease-of-use, there is a default config, but it creates a random keypair.
pub struct SatelliteConfig {
	/// The keypair used for network cryptography. It is the most important value for a satellite
	/// and must be kept safe.
	pub keypair: Keypair,
	pub mdns_config: SatelliteMdnsConfig,
	pub bootstrap: bool,
	pub auto_connect: bool,
}

#[derive(Clone)]
pub struct SatelliteMdnsConfig {
	// pub enable: bool,
	pub auto_register: bool,
}

impl Default for SatelliteMdnsConfig {
	fn default() -> Self {
		Self {
			// enable: true,
			auto_register: true,
		}
	}
}

impl Default for SatelliteConfig {
	fn default() -> Self {
		Self {
			keypair: crate::random_key(),
			mdns_config: Default::default(),
			bootstrap: true,
			auto_connect: true,
		}
	}
}

impl SatelliteConfig {
	/// Adds a Keypair to the config
	#[must_use]
	pub fn keypair(self, keypair: Keypair) -> Self {
		Self { keypair, ..self }
	}

	pub fn with_keypair(keypair: Keypair) -> Self {
		Self {
			keypair,
			..Default::default()
		}
	}

	// pub fn enable_mdns(self, enable: bool) -> Self {
	//     Self {
	//         mdns_config: SatelliteMdnsConfig {
	//             enable,
	//             ..self.mdns_config
	//         },
	//         ..self
	//     }
	// }
}