On 11/10/2025 8:43 AM, Alexandre Courbot wrote:
[..]
>
>> + |cmd| {
>> + self.current_offset += cmd.size_bytes();
>> + self.cmds_processed += 1;
>> + Some(Ok(cmd))
>> + },
>> + )
>> + }
>> +}
>> +
>> +impl<'a, 'b> IntoIterator for &'b GspSequencer<'a> {
>> + type Item = Result<GspSeqCmd>;
>> + type IntoIter = GspSeqIter<'b>;
>> +
>> + fn into_iter(self) -> Self::IntoIter {
>> + let cmd_data = &self.seq_info.cmd_data[..];
>> +
>> + GspSeqIter {
>> + cmd_data,
>> + current_offset: 0,
>> + total_cmds: self.seq_info.info.cmdIndex,
>> + cmds_processed: 0,
>> + dev: self.dev,
>> + }
>> + }
>> +}
>
> You can do without this implementation by just having an `iter` method
> returning the iterator where appropriate (in the current version this
> would be `GspSequencer`, but I suggest moving that to the
> `GspSequencerInfo/GspSequence`).
>
If I do that, it becomes ugly on the caller side.
Caller side becomes:
for cmd_result in sequencer.seq_info.iter(&sequencer.dev) {
..
}
instead of the current:
for cmd_result in sequencer {
..
}
Does it work for you if I remove IntoIterator and just have GspSequencer::iter()
return the iterator?
Then the caller becomes:
for cmd_result in sequencer.iter() {
..
}
Although I think IntoIterator makes a lot of sense here too, and there are other
usages of it in rust kernel code. But the sequencer.iter() would work for me.
Thanks.