code_gen/rust/common/with_access.rs
1use crate::rust::Access;
2use crate::{CodeBuffer, Expression};
3
4/// An element with an access level.
5pub trait WithAccess: Sized {
6 /// Gets the access level.
7 fn access(&self) -> &Access;
8
9 /// Sets the `access` level.
10 fn set_access<A>(&mut self, access: A)
11 where
12 A: Into<Access>;
13
14 /// Sets the `access` level.
15 fn with_access<A>(mut self, access: A) -> Self
16 where
17 A: Into<Access>,
18 {
19 self.set_access(access);
20 self
21 }
22
23 /// Writes the access level.
24 fn write_access(&self, b: &mut CodeBuffer) {
25 self.access().write(b);
26 }
27}