Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
albertotirla committed Mar 12, 2024
1 parent 9b089e7 commit 790447a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
20 changes: 10 additions & 10 deletions cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl Cache {
}

/// Remove a single cache item. This function can not fail.
#[tracing::instrument(level="trace", ret)]
#[tracing::instrument(level = "trace", ret)]

Check warning on line 726 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L726

Added line #L726 was not covered by tests
pub fn remove(&self, id: &CacheKey) {
self.by_id.remove(id);
}
Expand All @@ -732,7 +732,7 @@ impl Cache {
/// You will need to either get a read or a write lock on any item returned from this function.
/// It also may return `None` if a value is not matched to the key.
#[must_use]
#[tracing::instrument(level="trace", ret)]
#[tracing::instrument(level = "trace", ret)]

Check warning on line 735 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L735

Added line #L735 was not covered by tests
pub fn get_ref(&self, id: &CacheKey) -> Option<Arc<RwLock<CacheItem>>> {
self.by_id.get(id).as_deref().cloned()
}
Expand All @@ -742,14 +742,14 @@ impl Cache {
/// This will allow you to get the item without holding any locks to it,
/// at the cost of (1) a clone and (2) no guarantees that the data is kept up-to-date.
#[must_use]
#[tracing::instrument(level="trace", ret)]
#[tracing::instrument(level = "trace", ret)]

Check warning on line 745 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L745

Added line #L745 was not covered by tests
pub fn get(&self, id: &CacheKey) -> Option<CacheItem> {
Some(self.by_id.get(id).as_deref()?.read().ok()?.clone())
}

/// get a many items from the cache; this only creates one read handle (note that this will copy all data you would like to access)
#[must_use]
#[tracing::instrument(level="trace", ret)]
#[tracing::instrument(level = "trace", ret)]

Check warning on line 752 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L752

Added line #L752 was not covered by tests
pub fn get_all(&self, ids: &[CacheKey]) -> Vec<Option<CacheItem>> {
ids.iter().map(|id| self.get(id)).collect()
}
Expand All @@ -758,7 +758,7 @@ impl Cache {
/// associated with an id.
/// # Errors
/// An `Err(_)` variant may be returned if the [`Cache::populate_references`] function fails.
#[tracing::instrument(level="trace", ret, err)]
#[tracing::instrument(level = "trace", ret, err)]
pub fn add_all(&self, cache_items: Vec<CacheItem>) -> OdiliaResult<()> {
cache_items
.into_iter()
Expand All @@ -773,7 +773,7 @@ impl Cache {
.try_for_each(|item| Self::populate_references(&self.by_id, &item))
}
/// Bulk remove all ids in the cache; this only refreshes the cache after removing all items.
#[tracing::instrument(level="trace", ret)]
#[tracing::instrument(level = "trace", ret)]

Check warning on line 776 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L776

Added line #L776 was not covered by tests
pub fn remove_all(&self, ids: &Vec<CacheKey>) {
for id in ids {
self.by_id.remove(id);
Expand All @@ -788,7 +788,7 @@ impl Cache {
/// # Errors
///
/// An [`odilia_common::errors::OdiliaError::PoisoningError`] may be returned if a write lock can not be acquired on the `CacheItem` being modified.
#[tracing::instrument(level="trace", skip(modify), ret, err)]
#[tracing::instrument(level = "trace", skip(modify), ret, err)]

Check warning on line 791 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L791

Added line #L791 was not covered by tests
pub fn modify_item<F>(&self, id: &CacheKey, modify: F) -> OdiliaResult<bool>
where
F: FnOnce(&mut CacheItem),
Expand All @@ -815,7 +815,7 @@ impl Cache {
/// 1. The `accessible` can not be turned into an `AccessiblePrimitive`. This should never happen, but is technically possible.
/// 2. The [`Self::add`] function fails.
/// 3. The [`accessible_to_cache_item`] function fails.
#[tracing::instrument(level="debug", ret, err)]
#[tracing::instrument(level = "debug", ret, err)]

Check warning on line 818 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L818

Added line #L818 was not covered by tests
pub async fn get_or_create(
&self,
accessible: &AccessibleProxy<'_>,
Expand Down Expand Up @@ -843,7 +843,7 @@ impl Cache {
/// # Errors
/// If any references, either the ones passed in through the `item_ref` parameter, any children references, or the parent reference are unable to be unlocked, an `Err(_)` variant will be returned.
/// Technically it can also fail if the index of the `item_ref` in its parent exceeds `usize` on the given platform, but this is highly improbable.
#[tracing::instrument(level="trace", ret, err)]
#[tracing::instrument(level = "trace", ret, err)]
pub fn populate_references(
cache: &ThreadSafeCache,
item_ref: &Arc<RwLock<CacheItem>>,
Expand Down Expand Up @@ -895,7 +895,7 @@ impl Cache {
/// 1. The `cache` parameter does not reference an active cache once the `Weak` is upgraded to an `Option<Arc<_>>`.
/// 2. Any of the function calls on the `accessible` fail.
/// 3. Any `(String, OwnedObjectPath) -> AccessiblePrimitive` conversions fail. This *should* never happen, but technically it is possible.
#[tracing::instrument(level="trace", ret, err)]
#[tracing::instrument(level = "trace", ret, err)]

Check warning on line 898 in cache/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

cache/src/lib.rs#L898

Added line #L898 was not covered by tests
pub async fn accessible_to_cache_item(
accessible: &AccessibleProxy<'_>,
cache: Weak<Cache>,
Expand Down
6 changes: 3 additions & 3 deletions odilia/src/events/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::ScreenReaderState;
use atspi::events::{AddAccessibleEvent, CacheEvents, RemoveAccessibleEvent};
use odilia_cache::AccessiblePrimitive;

#[tracing::instrument(level="debug", skip(state), ret, err)]
#[tracing::instrument(level = "debug", skip(state), ret, err)]

Check warning on line 5 in odilia/src/events/cache.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/events/cache.rs#L5

Added line #L5 was not covered by tests
pub async fn dispatch(state: &ScreenReaderState, event: &CacheEvents) -> eyre::Result<()> {
match event {
CacheEvents::Add(add_event) => add_accessible(state, add_event).await?,
Expand All @@ -11,7 +11,7 @@ pub async fn dispatch(state: &ScreenReaderState, event: &CacheEvents) -> eyre::R
Ok(())
}

#[tracing::instrument(level="debug", skip(state), ret, err)]
#[tracing::instrument(level = "debug", skip(state), ret, err)]

Check warning on line 14 in odilia/src/events/cache.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/events/cache.rs#L14

Added line #L14 was not covered by tests
pub async fn add_accessible(
state: &ScreenReaderState,
event: &AddAccessibleEvent,
Expand All @@ -21,7 +21,7 @@ pub async fn add_accessible(
Ok(())
}

#[tracing::instrument(level="debug", skip(state), ret, err)]
#[tracing::instrument(level = "debug", skip(state), ret, err)]

Check warning on line 24 in odilia/src/events/cache.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/events/cache.rs#L24

Added line #L24 was not covered by tests
pub fn remove_accessible(
state: &ScreenReaderState,
event: &RemoveAccessibleEvent,
Expand Down
11 changes: 8 additions & 3 deletions odilia/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ async fn notifications_monitor(
state: Arc<ScreenReaderState>,
shutdown: CancellationToken,
) -> eyre::Result<()> {
let mut stream = listen_to_dbus_notifications().instrument(tracing::info_span!("creating notification listener")).await?;
let mut stream = listen_to_dbus_notifications()
.instrument(tracing::info_span!("creating notification listener"))
.await?;
loop {
tokio::select! {
Some(notification) = stream.next() => {
Expand Down Expand Up @@ -74,7 +76,7 @@ async fn sigterm_signal_watcher(
#[tracing::instrument]

Check warning on line 76 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L76

Added line #L76 was not covered by tests
#[tokio::main(flavor = "current_thread")]
async fn main() -> eyre::Result<()> {
let args = Args:: parse();
let args = Args::parse();
logging::init();

//initialize the primary token for task cancelation
Expand All @@ -84,7 +86,10 @@ async fn main() -> eyre::Result<()> {
let tracker = TaskTracker::new();

// Make sure applications with dynamic accessibility support do expose their AT-SPI2 interfaces.
if let Err(e) = atspi_connection::set_session_accessibility(true).instrument(tracing::info_span!("setting accessibility enabled flag")).await {
if let Err(e) = atspi_connection::set_session_accessibility(true)
.instrument(tracing::info_span!("setting accessibility enabled flag"))
.await
{
tracing::error!("Could not set AT-SPI2 IsEnabled property because: {}", e);

Check warning on line 93 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L93

Added line #L93 was not covered by tests
}
let (sr_event_tx, sr_event_rx) = mpsc::channel(128);
Expand Down

0 comments on commit 790447a

Please sign in to comment.