class Net::IMAP::CopyUIDData
NOTE: CopyUIDData will replace UIDPlusData for
COPYUIDin the0.6.0release. To useCopyUIDDatabefore0.6.0, setConfig#parser_use_deprecated_uidplus_datatofalse.
CopyUIDData represents the ResponseCode#data that accompanies the COPYUID response code.
A server that supports UIDPLUS (or IMAP4rev2) should send CopyUIDData in response to copy, uid_copy, move, and uid_move commands—unless the destination mailbox reports UIDNOTSTICKY.
Note that copy and uid_copy return CopyUIDData in their TaggedResponse. But move and uid_move should send CopyUIDData in an UntaggedResponse response before sending their TaggedResponse. However some servers do send CopyUIDData in the TaggedResponse for MOVE commands—this complies with the older UIDPLUS specification but is discouraged by the MOVE extension and disallowed by IMAP4rev2.
Required capability¶ ↑
Requires either UIDPLUS [RFC4315] or IMAP4rev2 capability.
Attributes
A SequenceSet with the newly assigned UIDs of the copied or moved messages.
A SequenceSet with the original UIDs of the copied or moved messages.
The UIDVALIDITY of the destination mailbox (a nonzero unsigned 32 bit integer).
Public Class Methods
Source
# File lib/net/imap/uidplus_data.rb, line 138 def initialize(uidvalidity:, source_uids:, assigned_uids:) uidvalidity = Integer(uidvalidity) source_uids = SequenceSet[source_uids] assigned_uids = SequenceSet[assigned_uids] NumValidator.ensure_nz_number(uidvalidity) if source_uids.include_star? || assigned_uids.include_star? raise DataFormatError, "uid-set cannot contain '*'" elsif source_uids.count_with_duplicates != assigned_uids.count_with_duplicates raise DataFormatError, "mismatched uid-set sizes for %s and %s" % [ source_uids, assigned_uids ] end super end
Public Instance Methods
Source
# File lib/net/imap/uidplus_data.rb, line 186 def assigned_uid_for(source_uid) idx = source_uids.find_ordered_index(source_uid) and assigned_uids.ordered_at(idx) end
Returns the UID in the destination mailbox for the message that was copied from source_uid in the source mailbox.
This is the reverse of source_uid_for.
Related: source_uid_for, each_uid_pair, uid_mapping
Source
# File lib/net/imap/uidplus_data.rb, line 216 def each_uid_pair return enum_for(__method__) unless block_given? source_uids.each_ordered_number.lazy .zip(assigned_uids.each_ordered_number.lazy) do |source_uid, assigned_uid| yield source_uid, assigned_uid end end
Yields a pair of UIDs for each copied message. The first is the message’s UID in the source mailbox and the second is the UID in the destination mailbox.
Returns an enumerator when no block is given.
Please note the warning on uid_mapping before calling methods like to_h or to_a on the returned enumerator.
Related: uid_mapping, assigned_uid_for, source_uid_for
Source
# File lib/net/imap/uidplus_data.rb, line 172 def size assigned_uids.count_with_duplicates end
Returns the number of messages that have been copied or moved. source_uids and the assigned_uids will both the same number of UIDs.
Source
# File lib/net/imap/uidplus_data.rb, line 201 def source_uid_for(assigned_uid) idx = assigned_uids.find_ordered_index(assigned_uid) and source_uids.ordered_at(idx) end
Returns the UID in the source mailbox for the message that was copied to assigned_uid in the source mailbox.
This is the reverse of assigned_uid_for.
Related: assigned_uid_for, each_uid_pair, uid_mapping
Source
# File lib/net/imap/uidplus_data.rb, line 237 def uid_mapping each_uid_pair.to_h end
Returns a hash mapping each source UID to the newly assigned destination UID.
Warning: The hash that is created may consume much more memory than the data used to create it. When handling responses from an untrusted server, check size before calling this method.
Related: each_uid_pair, assigned_uid_for, source_uid_for