'Generates the portion of the sync response. Populates
`sync_result_builder` with the result.
Args:
sync_result_builder(SyncResultBuilder)
Returns:
Deferred(dict): A dictionary containing the per room account data.'

@defer.inlineCallbacks
def _generate_sync_entry_for_to_device(self, sync_result_builder):

    user_id = sync_result_builder.sync_config.user.to_string()
    device_id = sync_result_builder.sync_config.device_id
    now_token = sync_result_builder.now_token
    since_stream_id = 0
    if (sync_result_builder.since_token is not None):
        since_stream_id = int(sync_result_builder.since_token.to_device_key)
    if (since_stream_id != int(now_token.to_device_key)):
        deleted = (yield self.store.delete_messages_for_device(user_id, device_id, since_stream_id))
        logger.debug('Deleted    %d    to-device    messages    up    to    %d', deleted, since_stream_id)
        (messages, stream_id) = (yield self.store.get_new_messages_for_device(user_id, device_id, since_stream_id, now_token.to_device_key))
        logger.debug('Returning    %d    to-device    messages    between    %d    and    %d    (current    token:    %d)', len(messages), since_stream_id, stream_id, now_token.to_device_key)
        sync_result_builder.now_token = now_token.copy_and_replace('to_device_key', stream_id)
        sync_result_builder.to_device = messages
    else:
        sync_result_builder.to_device = []
