Skip to content

Commit

Permalink
Merge pull request #89 from peterdelevoryas/master
Browse files Browse the repository at this point in the history
core: Relax lifetime constraint on `msgs` in `I2CTransfer::transfer()`
  • Loading branch information
eldruin authored Dec 20, 2024
2 parents 499e902 + e6fbc13 commit 69121a8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

ci-macos:
name: CI-macOS
runs-on: macos-11
runs-on: macos-14

strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Relax lifetime constraint on `I2CTransfer::transfer` `msgs` reference

## [v0.6.1] - 2024-05-09

- Properly ellide the start bit when sending a series of I2C messages as a
Expand Down
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub trait I2CTransfer<'a> {
/// Performs multiple serially chained I2C read/write transactions. On
/// success the return code is the number of successfully executed
/// transactions
fn transfer(&mut self, msgs: &'a mut [Self::Message]) -> Result<u32, Self::Error>;
fn transfer(&mut self, msgs: &mut [Self::Message]) -> Result<u32, Self::Error>;
}

/// Read/Write I2C message
Expand Down
4 changes: 2 additions & 2 deletions src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice {
type Message = LinuxI2CMessage<'a>;

/// Issue the provided sequence of I2C transactions
fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result<u32, LinuxI2CError> {
fn transfer(&mut self, messages: &mut [Self::Message]) -> Result<u32, LinuxI2CError> {
let msg_type = |flag: u16| flag & I2CMessageFlags::READ.bits();
let mut prev_msg_type = None;
for msg in messages.iter_mut() {
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CBus {
type Message = LinuxI2CMessage<'a>;

/// Issue the provided sequence of I2C transactions
fn transfer(&mut self, msgs: &'a mut [Self::Message]) -> Result<u32, LinuxI2CError> {
fn transfer(&mut self, msgs: &mut [Self::Message]) -> Result<u32, LinuxI2CError> {
ffi::i2c_rdwr(self.as_raw_fd(), msgs).map_err(From::from)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ where
type Message = MockI2CMessage<'a>;

/// Issue the provided sequence of I2C transactions
fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result<u32, Self::Error> {
fn transfer(&mut self, messages: &mut [Self::Message]) -> Result<u32, Self::Error> {
for msg in messages.iter_mut() {
match &mut msg.msg_type {
MessageType::Read(data) => self.read(data)?,
Expand Down

0 comments on commit 69121a8

Please sign in to comment.