unobtanium 3.0.0

Opinioated Web search engine library with crawler and viewer companion.
Documentation
use serde::{Deserialize,Serialize};
use uuid::Uuid;

use crate::time::UtcTimestamp;
use crate::time::now_utc;

/// A struct representing Crawling Agent metadata.
///
/// Use this at the start of a crawl or sceduling to register information
/// about the software in the crawler database.
#[derive(Debug,Serialize,Deserialize)]
pub struct Agent {
	/// The Software name i.e. `Unobtanium Explorer 1.0`
	pub name: String,
	/// The gent uuid that Uniquely identifies it.
	/// Recommended is a Uuid v7 so one could clean up a mess since the timestamp
	/// is encoded in the uuid too.
	pub uuid: Uuid,
	/// The http User agent used when making requests.
	pub http_user_agent: Option<String>,
	/// The timestamp when the agent started its work.
	pub time_started: UtcTimestamp,
	/// The timestamp when the agent finished its work.
	pub time_finished: Option<UtcTimestamp>,
}

impl Agent {

	/// Construct a new Agent with the current time as the start time and
	/// no finish time set.
	pub fn new(name: String, http_user_agent: Option<String>) -> Self {
		Self {
			name: name,
			uuid: Uuid::now_v7(),
			http_user_agent: http_user_agent,
			time_started: now_utc(),
			time_finished: None,
		}
	}
}