Skip to content

Commit

Permalink
refactor(global): suggest inline for opaque / trivial functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Jan 16, 2024
1 parent 3209238 commit dddd6de
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,63 +106,77 @@ pub struct TableOptions<'a> {
}

impl<'a> TableOptions<'a> {
#[inline]
pub fn get_ignore(&self) -> bool {
self.ignore.unwrap_or_default()
}

#[inline]
#[cfg(feature = "tsync")]
pub fn get_tsync(&self) -> bool {
self.tsync.unwrap_or_default()
}

#[inline]
#[cfg(feature = "async")]
pub fn get_async(&self) -> bool {
self.use_async.unwrap_or_default()
}

#[inline]
pub fn get_serde(&self) -> bool {
self.use_serde
}

#[inline]
pub fn get_fns(&self) -> bool {
self.fns
}

#[inline]
pub fn get_create_str_type(&self) -> StringType {
self.create_str_type
}

#[inline]
pub fn get_update_str_type(&self) -> StringType {
self.update_str_type
}

#[inline]
pub fn get_create_bytes_type(&self) -> BytesType {
self.create_bytes_type
}

#[inline]
pub fn get_update_bytes_type(&self) -> BytesType {
self.update_bytes_type
}

#[inline]
pub fn get_autogenerated_columns(&self) -> &[&'_ str] {
self.autogenerated_columns.as_deref().unwrap_or_default()
}

#[inline]
pub fn get_readonly(&self) -> bool {
self.read_only
}

#[inline]
pub fn get_single_model_file(&self) -> bool {
self.single_model_file
}

#[inline]
pub fn ignore(self) -> Self {
Self {
ignore: Some(true),
..self
}
}

#[inline]
#[cfg(feature = "tsync")]
pub fn tsync(self) -> Self {
Self {
Expand All @@ -171,6 +185,7 @@ impl<'a> TableOptions<'a> {
}
}

#[inline]
#[cfg(feature = "async")]
pub fn use_async(self) -> Self {
Self {
Expand All @@ -179,59 +194,68 @@ impl<'a> TableOptions<'a> {
}
}

#[inline]
pub fn disable_serde(self) -> Self {
Self {
use_serde: false,
..self
}
}

#[inline]
pub fn disable_fns(self) -> Self {
Self { fns: false, ..self }
}

#[inline]
pub fn single_model_file(self) -> Self {
Self {
single_model_file: true,
..self
}
}

#[inline]
pub fn autogenerated_columns(self, cols: Vec<&'a str>) -> Self {
Self {
autogenerated_columns: Some(cols),
..self
}
}

#[inline]
pub fn create_str_type(self, type_: StringType) -> Self {
Self {
create_str_type: type_,
..self
}
}

#[inline]
pub fn update_str_type(self, type_: StringType) -> Self {
Self {
update_str_type: type_,
..self
}
}

#[inline]
pub fn create_bytes_type(self, type_: BytesType) -> Self {
Self {
create_bytes_type: type_,
..self
}
}

#[inline]
pub fn update_bytes_type(self, type_: BytesType) -> Self {
Self {
update_bytes_type: type_,
..self
}
}

#[inline]
pub fn set_read_only(&mut self, value: bool) {
self.read_only = value;
}
Expand Down

0 comments on commit dddd6de

Please sign in to comment.