libmtp_rs/object/
properties.rs

1//! Contains all the properties that `libmtp` claims to support and can handle. Note that some
2//! devices and certain filetypes may not support some of these properties (but theorically every
3//! object should support all properties).
4
5use libmtp_sys as ffi;
6use num_derive::{FromPrimitive, ToPrimitive};
7use num_traits::ToPrimitive;
8use std::ffi::CStr;
9use std::fmt::{self, Display};
10
11/// Enumeration that holds the supported properties, this enum implements `Display` with the
12/// description of the property.
13#[derive(Debug, Clone, Copy, FromPrimitive, ToPrimitive)]
14pub enum Property {
15    StorageId = 0,
16    ObjectFormat,
17    ProtectionStatus,
18    ObjectSize,
19    AssociationType,
20    AssociationDesc,
21    ObjectFileName,
22    DateCreated,
23    DateModified,
24    Keywords,
25    ParentObject,
26    AllowedFolderContents,
27    Hidden,
28    SystemObject,
29    PersistantUniqueObjectIdentifier,
30    SyncId,
31    PropertyBag,
32    Name,
33    CreatedBy,
34    Artist,
35    DateAuthored,
36    Description,
37    UrlReference,
38    LanguageLocale,
39    CopyrightInformation,
40    Source,
41    OriginLocation,
42    DateAdded,
43    NonConsumable,
44    CorruptOrUnplayable,
45    ProducerSerialNumber,
46    RepresentativeSampleFormat,
47    RepresentativeSampleSize,
48    RepresentativeSampleHeight,
49    RepresentativeSampleWidth,
50    RepresentativeSampleDuration,
51    RepresentativeSampleData,
52    Width,
53    Height,
54    Duration,
55    Rating,
56    Track,
57    Genre,
58    Credits,
59    Lyrics,
60    SubscriptionContentId,
61    ProducedBy,
62    UseCount,
63    SkipCount,
64    LastAccessed,
65    ParentalRating,
66    MetaGenre,
67    Composer,
68    EffectiveRating,
69    Subtitle,
70    OriginalReleaseDate,
71    AlbumName,
72    AlbumArtist,
73    Mood,
74    DrmStatus,
75    SubDescription,
76    IsCropped,
77    IsColorCorrected,
78    ImageBitDepth,
79    Fnumber,
80    ExposureTime,
81    ExposureIndex,
82    DisplayName,
83    BodyText,
84    Subject,
85    Priority,
86    GivenName,
87    MiddleNames,
88    FamilyName,
89    Prefix,
90    Suffix,
91    PhoneticGivenName,
92    PhoneticFamilyName,
93    EmailPrimary,
94    EmailPersonal1,
95    EmailPersonal2,
96    EmailBusiness1,
97    EmailBusiness2,
98    EmailOthers,
99    PhoneNumberPrimary,
100    PhoneNumberPersonal,
101    PhoneNumberPersonal2,
102    PhoneNumberBusiness,
103    PhoneNumberBusiness2,
104    PhoneNumberMobile,
105    PhoneNumberMobile2,
106    FaxNumberPrimary,
107    FaxNumberPersonal,
108    FaxNumberBusiness,
109    PagerNumber,
110    PhoneNumberOthers,
111    PrimaryWebAddress,
112    PersonalWebAddress,
113    BusinessWebAddress,
114    InstantMessengerAddress,
115    InstantMessengerAddress2,
116    InstantMessengerAddress3,
117    PostalAddressPersonalFull,
118    PostalAddressPersonalFullLine1,
119    PostalAddressPersonalFullLine2,
120    PostalAddressPersonalFullCity,
121    PostalAddressPersonalFullRegion,
122    PostalAddressPersonalFullPostalCode,
123    PostalAddressPersonalFullCountry,
124    PostalAddressBusinessFull,
125    PostalAddressBusinessLine1,
126    PostalAddressBusinessLine2,
127    PostalAddressBusinessCity,
128    PostalAddressBusinessRegion,
129    PostalAddressBusinessPostalCode,
130    PostalAddressBusinessCountry,
131    PostalAddressOtherFull,
132    PostalAddressOtherLine1,
133    PostalAddressOtherLine2,
134    PostalAddressOtherCity,
135    PostalAddressOtherRegion,
136    PostalAddressOtherPostalCode,
137    PostalAddressOtherCountry,
138    OrganizationName,
139    PhoneticOrganizationName,
140    Role,
141    Birthdate,
142    MessageTo,
143    MessageCC,
144    MessageBCC,
145    MessageRead,
146    MessageReceivedTime,
147    MessageSender,
148    ActivityBeginTime,
149    ActivityEndTime,
150    ActivityLocation,
151    ActivityRequiredAttendees,
152    ActivityOptionalAttendees,
153    ActivityResources,
154    ActivityAccepted,
155    Owner,
156    Editor,
157    Webmaster,
158    UrlSource,
159    UrlDestination,
160    TimeBookmark,
161    ObjectBookmark,
162    ByteBookmark,
163    LastBuildDate,
164    TimeToLive,
165    MediaGuid,
166    TotalBitRate,
167    BitRateType,
168    SampleRate,
169    NumberOfChannels,
170    AudioBitDepth,
171    ScanDepth,
172    AudioWaveCodec,
173    AudioBitRate,
174    VideoFourCCCodec,
175    FramesPerThousandSeconds,
176    KeyFrameDistance,
177    BufferSize,
178    EncodingQuality,
179    EncodingProfile,
180    BuyFlag,
181    Unknown,
182}
183
184impl Display for Property {
185    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
186        let ptype = self.to_u32().expect("Unexpected Property variant?");
187        unsafe {
188            let desc = ffi::LIBMTP_Get_Property_Description(ptype);
189            let cstr = CStr::from_ptr(desc);
190
191            write!(f, "{}", cstr.to_str().unwrap())
192        }
193    }
194}