pub struct Bond { /* private fields */ }Expand description
Representation of a bond (source -> target)
The Bond struct encapsulates the properties of a bond, including its unique identifier, optional name, source and target paths, creation timestamp, and optional metadata. It provides methods for creating new bonds, accessing its fields, and serializing the creation timestamp for database storage. The struct is designed to be easily serializable to JSON for storage in a SQLite database and includes tests to ensure the uniqueness of IDs, correct serialization/deserialization, and proper handling of timestamps.
Implementations§
Source§impl Bond
impl Bond
Sourcepub fn new(source: PathBuf, target: PathBuf, name: Option<String>) -> Self
pub fn new(source: PathBuf, target: PathBuf, name: Option<String>) -> Self
Create a new Bond with a UUID and current timestamp.
Sourcepub fn created_at_rfc3339(&self) -> String
pub fn created_at_rfc3339(&self) -> String
Helper to serialize created_at for DB storage.
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Returns the timestamp when the bond was created.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bond
impl<'de> Deserialize<'de> for Bond
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Bond
impl StructuralPartialEq for Bond
Auto Trait Implementations§
impl Freeze for Bond
impl RefUnwindSafe for Bond
impl Send for Bond
impl Sync for Bond
impl Unpin for Bond
impl UnsafeUnpin for Bond
impl UnwindSafe for Bond
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.