Struct Stamp

Source
pub struct Stamp(/* private fields */);

Implementations§

Source§

impl Stamp

Source

pub fn new(stamp: u64) -> Self

Examples found in repository?
examples/compressed.rs (line 37)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let _ = fs::remove_dir_all("compressed");
13
14    let version = Version::TWO;
15
16    let database = Database::open(Path::new("compressed"))?;
17
18    let options = (&database, "vec", version).into();
19
20    {
21        let mut vec: VEC = CompressedVec::forced_import_with(options)?;
22
23        (0..21_u32).for_each(|v| {
24            vec.push(v);
25        });
26
27        let mut iter = vec.into_iter();
28        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
29        assert_eq!(iter.get(1), Some(Cow::Borrowed(&1)));
30        assert_eq!(iter.get(2), Some(Cow::Borrowed(&2)));
31        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
32        assert_eq!(iter.get(21), None);
33        drop(iter);
34
35        vec.flush()?;
36
37        assert_eq!(vec.header().stamp(), Stamp::new(0));
38    }
39
40    {
41        let mut vec: VEC = CompressedVec::forced_import_with(options)?;
42
43        vec.mut_header().update_stamp(Stamp::new(100));
44
45        assert!(vec.header().stamp() == Stamp::new(100));
46
47        let mut iter = vec.into_iter();
48        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
49        assert_eq!(iter.get(1), Some(Cow::Borrowed(&1)));
50        assert_eq!(iter.get(2), Some(Cow::Borrowed(&2)));
51        assert_eq!(iter.get(3), Some(Cow::Borrowed(&3)));
52        assert_eq!(iter.get(4), Some(Cow::Borrowed(&4)));
53        assert_eq!(iter.get(5), Some(Cow::Borrowed(&5)));
54        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
55        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
56        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
57        drop(iter);
58
59        vec.push(21);
60        vec.push(22);
61
62        assert_eq!(vec.stored_len(), 21);
63        assert_eq!(vec.pushed_len(), 2);
64        assert_eq!(vec.len(), 23);
65
66        let mut iter = vec.into_iter();
67        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
68        assert_eq!(iter.get(21), Some(Cow::Borrowed(&21)));
69        assert_eq!(iter.get(22), Some(Cow::Borrowed(&22)));
70        assert_eq!(iter.get(23), None);
71        drop(iter);
72
73        vec.flush()?;
74    }
75
76    {
77        let mut vec: VEC = CompressedVec::forced_import_with(options)?;
78
79        assert_eq!(vec.header().stamp(), Stamp::new(100));
80
81        assert_eq!(vec.stored_len(), 23);
82        assert_eq!(vec.pushed_len(), 0);
83        assert_eq!(vec.len(), 23);
84
85        let mut iter = vec.into_iter();
86        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
87        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
88        assert_eq!(iter.get(21), Some(Cow::Borrowed(&21)));
89        assert_eq!(iter.get(22), Some(Cow::Borrowed(&22)));
90        drop(iter);
91
92        vec.truncate_if_needed(14)?;
93
94        assert_eq!(vec.stored_len(), 14);
95        assert_eq!(vec.pushed_len(), 0);
96        assert_eq!(vec.len(), 14);
97
98        let mut iter = vec.into_iter();
99        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
100        assert_eq!(iter.get(5), Some(Cow::Borrowed(&5)));
101        assert_eq!(iter.get(20), None);
102        drop(iter);
103
104        assert_eq!(
105            vec.collect_signed_range(Some(-5), None)?,
106            vec![9, 10, 11, 12, 13]
107        );
108
109        vec.push(vec.len() as u32);
110        assert_eq!(
111            VecIterator::last(vec.into_iter()),
112            Some((14, Cow::Borrowed(&14)))
113        );
114
115        vec.flush()?;
116
117        assert_eq!(
118            vec.into_iter()
119                .map(|(_, v)| v.into_owned())
120                .collect::<Vec<_>>(),
121            vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
122        );
123    }
124
125    {
126        let mut vec: VEC = CompressedVec::forced_import_with(options)?;
127
128        assert_eq!(
129            vec.into_iter()
130                .map(|(_, v)| v.into_owned())
131                .collect::<Vec<_>>(),
132            vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
133        );
134
135        let mut iter = vec.into_iter();
136        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
137        assert_eq!(iter.get(5), Some(Cow::Borrowed(&5)));
138        assert_eq!(iter.get(20), None);
139        drop(iter);
140
141        assert_eq!(
142            vec.collect_signed_range(Some(-5), None)?,
143            vec![10, 11, 12, 13, 14]
144        );
145
146        vec.reset()?;
147
148        assert_eq!(vec.pushed_len(), 0);
149        assert_eq!(vec.stored_len(), 0);
150        assert_eq!(vec.len(), 0);
151
152        (0..21_u32).for_each(|v| {
153            vec.push(v);
154        });
155
156        assert_eq!(vec.pushed_len(), 21);
157        assert_eq!(vec.stored_len(), 0);
158        assert_eq!(vec.len(), 21);
159
160        let mut iter = vec.into_iter();
161        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
162        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
163        assert_eq!(iter.get(21), None);
164        drop(iter);
165
166        vec.flush()?;
167    }
168
169    {
170        let mut vec: VEC = CompressedVec::forced_import_with(options)?;
171
172        assert_eq!(vec.pushed_len(), 0);
173        assert_eq!(vec.stored_len(), 21);
174        assert_eq!(vec.len(), 21);
175
176        let reader = vec.create_static_reader();
177        assert_eq!(vec.holes(), &BTreeSet::new());
178        assert_eq!(vec.get_or_read(0, &reader)?, Some(Cow::Borrowed(&0)));
179        assert_eq!(vec.get_or_read(10, &reader)?, Some(Cow::Borrowed(&10)));
180        drop(reader);
181
182        vec.flush()?;
183    }
184
185    {
186        let vec: VEC = CompressedVec::forced_import_with(options)?;
187
188        assert!(
189            vec.collect()?
190                == vec![
191                    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
192                ]
193        );
194    }
195
196    Ok(())
197}
More examples
Hide additional examples
examples/raw.rs (line 37)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let _ = fs::remove_dir_all("raw");
13
14    let version = Version::TWO;
15
16    let database = Database::open(Path::new("raw"))?;
17
18    let mut options = (&database, "vec", version).into();
19
20    {
21        let mut vec: VEC = RawVec::forced_import_with(options)?;
22
23        (0..21_u32).for_each(|v| {
24            vec.push(v);
25        });
26
27        let mut iter = vec.into_iter();
28        assert!(iter.get(0) == Some(Cow::Borrowed(&0)));
29        assert!(iter.get(1) == Some(Cow::Borrowed(&1)));
30        assert!(iter.get(2) == Some(Cow::Borrowed(&2)));
31        assert!(iter.get(20) == Some(Cow::Borrowed(&20)));
32        assert!(iter.get(21).is_none());
33        drop(iter);
34
35        vec.flush()?;
36
37        assert!(vec.header().stamp() == Stamp::new(0));
38    }
39
40    {
41        let mut vec: VEC = RawVec::forced_import_with(options)?;
42
43        vec.mut_header().update_stamp(Stamp::new(100));
44
45        assert!(vec.header().stamp() == Stamp::new(100));
46
47        let mut iter = vec.into_iter();
48        assert!(iter.get(0) == Some(Cow::Borrowed(&0)));
49        assert!(iter.get(1) == Some(Cow::Borrowed(&1)));
50        assert!(iter.get(2) == Some(Cow::Borrowed(&2)));
51        assert!(iter.get(3) == Some(Cow::Borrowed(&3)));
52        assert!(iter.get(4) == Some(Cow::Borrowed(&4)));
53        assert!(iter.get(5) == Some(Cow::Borrowed(&5)));
54        assert!(iter.get(20) == Some(Cow::Borrowed(&20)));
55        assert!(iter.get(20) == Some(Cow::Borrowed(&20)));
56        assert!(iter.get(0) == Some(Cow::Borrowed(&0)));
57        drop(iter);
58
59        vec.push(21);
60        vec.push(22);
61
62        assert!(vec.stored_len() == 21);
63        assert!(vec.pushed_len() == 2);
64        assert!(vec.len() == 23);
65
66        let mut iter = vec.into_iter();
67        assert!(iter.get(20) == Some(Cow::Borrowed(&20)));
68        assert!(iter.get(21) == Some(Cow::Borrowed(&21)));
69        assert!(iter.get(22) == Some(Cow::Borrowed(&22)));
70        assert!(iter.get(23).is_none());
71        drop(iter);
72
73        vec.flush()?;
74    }
75
76    {
77        let mut vec: VEC = RawVec::forced_import_with(options)?;
78
79        assert!(vec.header().stamp() == Stamp::new(100));
80
81        assert!(vec.stored_len() == 23);
82        assert!(vec.pushed_len() == 0);
83        assert!(vec.len() == 23);
84
85        let mut iter = vec.into_iter();
86        assert!(iter.get(0) == Some(Cow::Borrowed(&0)));
87        assert!(iter.get(20) == Some(Cow::Borrowed(&20)));
88        assert!(iter.get(21) == Some(Cow::Borrowed(&21)));
89        assert!(iter.get(22) == Some(Cow::Borrowed(&22)));
90        drop(iter);
91
92        vec.truncate_if_needed(14)?;
93
94        assert_eq!(vec.stored_len(), 14);
95        assert_eq!(vec.pushed_len(), 0);
96        assert_eq!(vec.len(), 14);
97
98        let mut iter = vec.into_iter();
99        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
100        assert_eq!(iter.get(5), Some(Cow::Borrowed(&5)));
101        assert_eq!(iter.get(20), None);
102        drop(iter);
103
104        assert_eq!(
105            vec.collect_signed_range(Some(-5), None)?,
106            vec![9, 10, 11, 12, 13]
107        );
108
109        vec.push(vec.len() as u32);
110        assert_eq!(
111            VecIterator::last(vec.into_iter()),
112            Some((14, Cow::Borrowed(&14)))
113        );
114
115        assert_eq!(
116            vec.into_iter()
117                .map(|(_, v)| v.into_owned())
118                .collect::<Vec<_>>(),
119            vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
120        );
121
122        vec.flush()?;
123    }
124
125    {
126        let mut vec: VEC = RawVec::forced_import_with(options)?;
127
128        assert_eq!(
129            VecIterator::last(vec.into_iter()),
130            Some((14, Cow::Borrowed(&14)))
131        );
132
133        assert_eq!(
134            vec.into_iter()
135                .map(|(_, v)| v.into_owned())
136                .collect::<Vec<_>>(),
137            vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
138        );
139
140        vec.reset()?;
141
142        assert_eq!(vec.pushed_len(), 0);
143        assert_eq!(vec.stored_len(), 0);
144        assert_eq!(vec.len(), 0);
145
146        (0..21_u32).for_each(|v| {
147            vec.push(v);
148        });
149
150        assert_eq!(vec.pushed_len(), 21);
151        assert_eq!(vec.stored_len(), 0);
152        assert_eq!(vec.len(), 21);
153
154        let mut iter = vec.into_iter();
155        assert_eq!(iter.get(0), Some(Cow::Borrowed(&0)));
156        assert_eq!(iter.get(20), Some(Cow::Borrowed(&20)));
157        assert!(iter.get(21).is_none());
158        drop(iter);
159
160        let reader = vec.create_static_reader();
161        assert_eq!(vec.take(10, &reader)?, Some(10));
162        assert_eq!(vec.holes(), &BTreeSet::from([10]));
163        assert!(vec.get_or_read(10, &reader)?.is_none());
164        drop(reader);
165
166        vec.flush()?;
167
168        assert!(vec.holes() == &BTreeSet::from([10]));
169    }
170
171    {
172        let mut vec: VEC = RawVec::forced_import_with(options)?;
173
174        assert!(vec.holes() == &BTreeSet::from([10]));
175
176        let reader = vec.create_static_reader();
177        assert!(vec.get_or_read(10, &reader)?.is_none());
178        drop(reader);
179
180        vec.update(10, 10)?;
181        vec.update(0, 10)?;
182
183        let reader = vec.create_static_reader();
184        assert_eq!(vec.holes(), &BTreeSet::new());
185        assert_eq!(vec.get_or_read(0, &reader)?, Some(Cow::Borrowed(&10)));
186        assert_eq!(vec.get_or_read(10, &reader)?, Some(Cow::Borrowed(&10)));
187        drop(reader);
188
189        vec.flush()?;
190    }
191
192    options = options.with_saved_stamped_changes(10);
193
194    {
195        let mut vec: VEC = RawVec::forced_import_with(options)?;
196
197        assert_eq!(
198            vec.collect()?,
199            vec![
200                10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
201            ]
202        );
203
204        vec.truncate_if_needed(10)?;
205
206        let reader = vec.create_static_reader();
207        vec.take(5, &reader)?;
208        vec.update(3, 5)?;
209        vec.push(21);
210        drop(reader);
211
212        assert_eq!(
213            vec.collect_holed()?,
214            vec![
215                Some(10),
216                Some(1),
217                Some(2),
218                Some(5),
219                Some(4),
220                None,
221                Some(6),
222                Some(7),
223                Some(8),
224                Some(9),
225                Some(21)
226            ]
227        );
228
229        vec.stamped_flush(Stamp::new(1))?;
230    }
231
232    {
233        let mut vec: VEC = RawVec::forced_import_with(options)?;
234
235        assert_eq!(vec.collect()?, vec![10, 1, 2, 5, 4]);
236
237        let reader = vec.create_static_reader();
238        vec.take(0, &reader)?;
239        vec.update(1, 5)?;
240        vec.push(5);
241        vec.push(6);
242        vec.push(7);
243        drop(reader);
244
245        assert_eq!(
246            vec.collect_holed()?,
247            vec![
248                None,
249                Some(5),
250                Some(2),
251                Some(5),
252                Some(4),
253                None,
254                Some(6),
255                Some(7),
256                Some(8),
257                Some(9),
258                Some(21),
259                Some(5),
260                Some(6),
261                Some(7)
262            ]
263        );
264
265        vec.stamped_flush(Stamp::new(2))?;
266    }
267
268    {
269        let mut vec: VEC = RawVec::forced_import_with(options)?;
270
271        assert_eq!(
272            vec.collect_holed()?,
273            vec![
274                None,
275                Some(5),
276                Some(2),
277                Some(5),
278                Some(4),
279                None,
280                Some(6),
281                Some(7),
282                Some(8),
283                Some(9),
284                Some(21),
285                Some(5),
286                Some(6),
287                Some(7)
288            ]
289        );
290
291        vec.rollback_stamp(Stamp::new(2))?;
292
293        assert_eq!(
294            vec.collect_holed()?,
295            vec![
296                Some(10),
297                Some(1),
298                Some(2),
299                Some(5),
300                Some(4),
301                None,
302                Some(6),
303                Some(7),
304                Some(8),
305                Some(9),
306                Some(21)
307            ]
308        );
309
310        vec.rollback_stamp(Stamp::new(1))?;
311
312        assert_eq!(
313            vec.collect()?,
314            vec![
315                10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
316            ]
317        );
318
319        // vec.stamped_flush(Stamp::new(1))?;
320    }
321
322    Ok(())
323}

Trait Implementations§

Source§

impl Clone for Stamp

Source§

fn clone(&self) -> Stamp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stamp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Stamp

Source§

fn default() -> Stamp

Returns the “default value” for a type. Read more
Source§

impl From<Stamp> for u64

Source§

fn from(value: Stamp) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Stamp

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl FromBytes for Stamp
where u64: FromBytes,

Source§

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self. Read more
Source§

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying. Read more
Source§

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &Self. Read more
Source§

fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the given source as a &mut Self. Read more
Source§

fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the prefix of the given source as a &mut Self without copying. Read more
Source§

fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the suffix of the given source as a &mut Self without copying. Read more
Source§

fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the given source. Read more
Source§

fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the prefix of the given source. Read more
Source§

fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the suffix of the given source. Read more
Source§

impl FromZeros for Stamp
where u64: FromZeros,

Source§

fn zero(&mut self)

Overwrites self with zeros. Read more
Source§

fn new_zeroed() -> Self
where Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
Source§

impl IntoBytes for Stamp
where u64: IntoBytes, (): PaddingFree<Self, { _ }>,

Source§

fn as_bytes(&self) -> &[u8]
where Self: Immutable,

Gets the bytes of this value. Read more
Source§

fn as_mut_bytes(&mut self) -> &mut [u8]
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
Source§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
Source§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
Source§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

impl KnownLayout for Stamp
where Self: Sized,

Source§

type PointerMetadata = ()

The type of metadata stored in a pointer to Self. Read more
Source§

impl Ord for Stamp

Source§

fn cmp(&self, other: &Stamp) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Stamp

Source§

fn eq(&self, other: &Stamp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Stamp

Source§

fn partial_cmp(&self, other: &Stamp) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFromBytes for Stamp

Source§

fn try_ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the given source as a &Self. Read more
Source§

fn try_ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the prefix of the given source as a &Self. Read more
Source§

fn try_ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the suffix of the given source as a &Self. Read more
Source§

fn try_mut_from_bytes( bytes: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the given source as a &mut Self without copying. Read more
Source§

fn try_mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the prefix of the given source as a &mut Self. Read more
Source§

fn try_mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the suffix of the given source as a &mut Self. Read more
Source§

fn try_read_from_bytes( source: &[u8], ) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read the given source as a Self. Read more
Source§

fn try_read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the prefix of the given source. Read more
Source§

fn try_read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the suffix of the given source. Read more
Source§

impl Copy for Stamp

Source§

impl Eq for Stamp

Source§

impl Immutable for Stamp
where u64: Immutable,

Source§

impl StructuralPartialEq for Stamp

Auto Trait Implementations§

§

impl Freeze for Stamp

§

impl RefUnwindSafe for Stamp

§

impl Send for Stamp

§

impl Sync for Stamp

§

impl Unpin for Stamp

§

impl UnwindSafe for Stamp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.