Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// Generate `rust-project.json` with bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
"rust-analyzer.linkedProjects": [
"rust-project.json"
]
}
8 changes: 8 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "rules_doxygen", version = "2.5.0")
bazel_dep(name = "score_baselibs", version = "0.2.2")

bazel_dep(name = "score_baselibs_rust", version = "0.0.1")
git_override(
module_name = "score_baselibs_rust",
commit = "9ee64ac85f2a990ef75b2858253ee44bfc1a7ab7",
remote = "https://github.com/eclipse-score/baselibs_rust.git",
)


# Doxygen extension for documentation generation
doxygen_extension = use_extension("@rules_doxygen//:extensions.bzl", "doxygen_extension")
use_repo(doxygen_extension, "doxygen")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<R: Runtime> VehicleMonitor<R> {

/// Monitor tire data from the consumer
pub fn read_tire_data(&self) -> Result<String> {
let mut sample_buf = SampleContainer::new();
let mut sample_buf = SampleContainer::new(3);

match self.tire_subscriber.try_receive(&mut sample_buf, 1) {
Ok(0) => Err(Error::Fail),
Expand Down
4 changes: 3 additions & 1 deletion score/mw/com/impl/rust/com-api/com-api-concept/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ rust_library(
visibility = [
"//visibility:public", # platform_only
],
deps = [],
deps = [
"@score_baselibs_rust//src/containers:containers",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a split between baselibs and baselibs_rust?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the decision longer time ago in TL meeting agreed wit @4og and @antonkri . Later maybe those will be merged.

],
)

rust_test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ use core::fmt::Debug;
use core::future::Future;
use core::ops::{Deref, DerefMut};
pub mod reloc;
use containers::fixed_capacity::FixedCapacityQueue;
pub use reloc::Reloc;
use std::collections::VecDeque;
use std::path::Path;

/// Error enumeration for different failure cases in the Consumer/Producer/Runtime APIs.
Expand Down Expand Up @@ -597,21 +597,15 @@ pub trait Subscriber<T: Reloc + Send + Debug, R: Runtime + ?Sized> {
/// # Type Parameters
/// * `S`: The sample type stored in the container.
pub struct SampleContainer<S> {
inner: VecDeque<S>,
}

impl<S> Default for SampleContainer<S> {
fn default() -> Self {
Self {
inner: VecDeque::new(),
}
}
inner: FixedCapacityQueue<S>,
}

impl<S> SampleContainer<S> {
/// Creates a new, empty `SampleContainer`
pub fn new() -> Self {
Self::default()
pub fn new(capacity: usize) -> Self {
Self {
inner: FixedCapacityQueue::new(capacity),
}
}

/// Returns an iterator over references to the samples in the container.
Expand Down Expand Up @@ -645,7 +639,7 @@ impl<S> SampleContainer<S> {
/// # Returns
/// A `Result` indicating success or failure.
pub fn push_back(&mut self, new: S) -> Result<()> {
self.inner.push_back(new);
self.inner.push_back(new).map_err(|_| Error::AllocateFailed)?;
Ok(())
}

Expand Down
Loading