Skip to content

Commit 4dea59e

Browse files
Accessor: Document lack of multi-value support
Co-authored-by: Serial <[email protected]> Signed-off-by: Serial <[email protected]>
1 parent 2ce196f commit 4dea59e

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lofty/src/tag/accessor.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use std::borrow::Cow;
22

3+
#[cfg(doc)]
4+
use crate::{ogg::tag::VorbisComments, tag::Tag};
5+
36
// This defines the `Accessor` trait, used to define unified getters/setters for commonly
47
// accessed tag values.
58
//
@@ -26,6 +29,10 @@ macro_rules! accessor_trait {
2629
///
2730
/// This attempts to only provide methods for items that all tags have in common,
2831
/// but there may be exceptions.
32+
///
33+
/// Note that for tag formats supporting multiple values, the behavior of any setter methods is
34+
/// to **overwrite**, not append. If multi-value support is needed, consider using the format-specific methods.
35+
/// For example: [`Tag::push()`] or [`VorbisComments::push()`].
2936
pub trait Accessor {
3037
$(
3138
accessor_trait! { @GETTER [$($name)+] $($ty),+ }
@@ -53,7 +60,13 @@ macro_rules! accessor_trait {
5360
};
5461
(@GET_METHOD [$name:tt $($other:tt)*] Option<$ret_ty:ty>) => {
5562
paste::paste! {
56-
#[doc = "Returns the " $name $(" " $other)*]
63+
#[doc = "Returns the " $name $(" " $other)* "."]
64+
///
65+
/// For formats that support multiple definitions of the same item, this will only return the first occurrence.
66+
///
67+
/// To retrieve all occurrences of a given item, consider using the format-specific methods.
68+
/// For example: [`Tag::get_items()`] or [`VorbisComments::get_all()`].
69+
///
5770
/// # Example
5871
///
5972
/// ```rust
@@ -70,7 +83,14 @@ macro_rules! accessor_trait {
7083
};
7184
(@SET_METHOD [$name:tt $($other:tt)*] $owned_ty:ty) => {
7285
paste::paste! {
73-
#[doc = "Sets the " $name $(" " $other)*]
86+
#[doc = "Sets the " $name $(" " $other)* "."]
87+
///
88+
/// For formats that support multiple definitions of the same item, this will remove **all**
89+
/// existing values, and replace them with `value`.
90+
///
91+
/// To define multiple values, consider using the format-specific methods.
92+
/// For example: [`Tag::push()`] or [`VorbisComments::push()`].
93+
///
7494
/// # Example
7595
///
7696
/// ```rust,ignore

0 commit comments

Comments
 (0)