Skip to content

PathBuf is not supported as a property #1729

Description

@olvrlrnz

Hi,

I have a service which exposes some properties. When I tried to add another one of type Vec<PathBuf>, it fails to compile

error[E0277]: the trait bound `Vec<PathBuf>: TryFrom<OwnedValue>` is not satisfied
   --> src/lib.rs:34:31
    |
 34 |     fn property_one(&self) -> zbus::fdo::Result<Vec<PathBuf>>;
    |                               ^^^^ the trait `TryFrom<OwnedValue>` is not implemented for `Vec<PathBuf>`

I read #977 but FilePath doesn't help here. I hacked together impl From<PathBuf> for OwnedValue and impl<'v> From<PathBuf> for Value<'v> to send OsStrExt::as_bytes - and it worked.

I do understand the requirement for OwnedValue and the lossy PathBuf -> String -> PathBuf cycle, but what's the alternative - use a newtype and manually implement the required traits?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions