[pbs-devel] [RFC proxmox-backup 07/24] server: sync: move reader trait to common sync module

Christian Ebner c.ebner at proxmox.com
Tue Jul 23 09:32:28 CEST 2024


On 7/16/24 11:53, Gabriel Goller wrote:
> On 15.07.2024 12:15, Christian Ebner wrote:
>> pub(crate) struct PullTarget {
>>     store: Arc<DataStore>,
>>     ns: BackupNamespace,
>> @@ -97,7 +85,7 @@ trait PullSource: Send + Sync {
>>         &self,
>>         ns: &BackupNamespace,
>>         dir: &BackupDir,
>> -    ) -> Result<Arc<dyn PullReader>, Error>;
>> +    ) -> Result<Arc<dyn SyncSourceReader>, Error>;
>> }
>>
>> #[async_trait::async_trait]
> 
> AFAIK we are currently on rust 1.79.0, which has async fn's in traits
> already stabilized. This means we can remove the async_trait create.
> https://releases.rs/docs/1.75.0/

Thanks for pointing this out!

However, dropping the `async_trait` macro does not work out, as these 
traits are used as base for trait objects, which therefore require the 
trait to be object safe, see 
https://doc.rust-lang.org/reference/items/traits.html#object-safety

So the Rust compiler complains with, e.g.

```
error[E0038]: the trait `SyncSource` cannot be made into an object
```

Therefore I would opt to keep this as is, unless I'm overlooking 
something here.




More information about the pbs-devel mailing list