Struct kas_core::event::UpdateId

source ·
pub struct UpdateId(_);
Expand description

An update identifier

Used to identify the origin of an Event::Update.

Implementations§

Zero: used when a unique identifier isn’t required

Issue a new UpdateId

A total of 232 - 1 update handles are available. Attempting to issue 232 handles will result in a panic.

Examples found in repository?
src/model/shared_rc.rs (line 26)
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    fn default() -> Self {
        SharedRc(Rc::new((UpdateId::new(), Default::default())))
    }
}

/// A borrowed reference
pub struct SharedRcRef<'a, T>(Ref<'a, T>);
impl<'a, T> std::borrow::Borrow<T> for SharedRcRef<'a, T> {
    fn borrow(&self) -> &T {
        &self.0
    }
}
impl<'a, T> Deref for SharedRcRef<'a, T> {
    type Target = T;
    fn deref(&self) -> &T {
        &self.0
    }
}

/// A mutably borrowed reference
pub struct SharedRcRefMut<'a, T>(RefMut<'a, T>);
impl<'a, T> std::borrow::Borrow<T> for SharedRcRefMut<'a, T> {
    fn borrow(&self) -> &T {
        &self.0
    }
}
impl<'a, T> std::borrow::BorrowMut<T> for SharedRcRefMut<'a, T> {
    fn borrow_mut(&mut self) -> &mut T {
        &mut self.0
    }
}
impl<'a, T> Deref for SharedRcRefMut<'a, T> {
    type Target = T;
    fn deref(&self) -> &T {
        &self.0
    }
}
impl<'a, T> DerefMut for SharedRcRefMut<'a, T> {
    fn deref_mut(&mut self) -> &mut T {
        &mut self.0
    }
}

impl<T: Debug> SharedRc<T> {
    /// Construct with given data
    pub fn new(data: T) -> Self {
        let id = UpdateId::new();
        let data = RefCell::new((data, 1));
        SharedRc(Rc::new((id, data)))
    }
More examples
Hide additional examples
src/model/shared_arc.rs (line 25)
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
    fn default() -> Self {
        SharedArc(Arc::new((UpdateId::new(), Default::default())))
    }
}

/// A borrowed reference
pub struct SharedArcRef<'a, T>(MutexGuard<'a, (T, u64)>);
impl<'a, T> std::borrow::Borrow<T> for SharedArcRef<'a, T> {
    fn borrow(&self) -> &T {
        &self.0.deref().0
    }
}
impl<'a, T> Deref for SharedArcRef<'a, T> {
    type Target = T;
    fn deref(&self) -> &T {
        &self.0.deref().0
    }
}

/// A mutably borrowed reference
//
// Note: this is identical to SharedArcRef other than the trait impls. We cannot
// allow SharedData::borrow to return a type supporting mutable access!
pub struct SharedArcRefMut<'a, T>(MutexGuard<'a, (T, u64)>);
impl<'a, T> std::borrow::Borrow<T> for SharedArcRefMut<'a, T> {
    fn borrow(&self) -> &T {
        &self.0.deref().0
    }
}
impl<'a, T> std::borrow::BorrowMut<T> for SharedArcRefMut<'a, T> {
    fn borrow_mut(&mut self) -> &mut T {
        &mut self.0.deref_mut().0
    }
}
impl<'a, T> Deref for SharedArcRefMut<'a, T> {
    type Target = T;
    fn deref(&self) -> &T {
        &self.0.deref().0
    }
}
impl<'a, T> DerefMut for SharedArcRefMut<'a, T> {
    fn deref_mut(&mut self) -> &mut T {
        &mut self.0.deref_mut().0
    }
}

impl<T: Debug> SharedArc<T> {
    /// Construct with given data
    pub fn new(data: T) -> Self {
        let id = UpdateId::new();
        let data = Mutex::new((data, 1));
        SharedArc(Arc::new((id, data)))
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Cast from Self to T Read more
Try converting from Self to T Read more
Try approximate conversion from Self to T Read more
Cast approximately from Self to T Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Cast the ceiling to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.