Skip to content
Merged
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
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
-

## [0.3.2][] - 2024-01-14

### Added

- Add `Clone` and `Copy` implementations for `InterchangeRef`.

## [0.3.1][] - 2024-06-20

Expand Down Expand Up @@ -35,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changes API to use references instead of moves.
This improves stack usage.

[Unreleased]: https://github.com/trussed-dev/interchange/compare/0.3.1...HEAD
[Unreleased]: https://github.com/trussed-dev/interchange/compare/0.3.2...HEAD
[0.3.2]: https://github.com/trussed-dev/interchange/compare/0.3.1...0.3.2
[0.3.1]: https://github.com/trussed-dev/interchange/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/trussed-dev/interchange/compare/0.2.2...0.3.0
[0.2.2]: https://github.com/trussed-dev/interchange/compare/0.2.0...0.2.2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "interchange"
version = "0.3.1"
version = "0.3.2"
authors = ["The Trussed developers", "Nicolas Stalder <n@stalder.io>"]
edition = "2018"
description = "Request/response mechanism for embedded development, using atomics"
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ pub struct InterchangeRef<'alloc, Rq, Rp> {
channels: &'alloc [Channel<Rq, Rp>],
last_claimed: &'alloc AtomicUsize,
}

impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
/// Claim one of the channels of the interchange. Returns None if called more than `N` times.
pub fn claim(&self) -> Option<(Requester<'alloc, Rq, Rp>, Responder<'alloc, Rq, Rp>)> {
Expand All @@ -964,6 +965,14 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
}
}

impl<Rq, Rp> Clone for InterchangeRef<'_, Rq, Rp> {
fn clone(&self) -> Self {
*self
}
}

impl<Rq, Rp> Copy for InterchangeRef<'_, Rq, Rp> {}

impl<Rq, Rp, const N: usize> Default for Interchange<Rq, Rp, N> {
fn default() -> Self {
Self::new()
Expand Down
Loading