Dual Modbus RTU connections

I need get Arduino to be at the same time Modbus master and slave towards to devices. In a way Arduino should be sort of mediator between.
I am familiar with ModbusMaster library which is quite ok but it does not support slave at all.
ArduinoModbus (which uses ArduinoRS485) can be hacked to use HW serial by modifying RS485.cpp but in that it can only be used with one serial port.

Is there library capable for two HW serial ports, one for master and pone for slave?

Sounds like an abuse of the protocol.

ArduinoModbus shouldn't be used on AVR Arduinos, it's designed to be used on MKR Arduinos. It supports multiple serial connections although the usage isn't straightforward then.

Modbus-Master-Slave-for-Arduino (often called ModbusRTU.h) is a rather lightweight implementation of both master and slave in one library. As you didn't specify what requirements you have, recommending a specific library is difficult if not impossible.

Keep in mind that usually the slave part isn't available on the bus while the master part is active on the other bus (to enforce the rather strict timing of Modbus).

The point is to have two separate RS485 busses. One where Arduino behaves as master and another where master. These are with separate HW serial ports too. So, Arduino is real mediator.
The problem is that ArduinoModbus library either is not capable to be used as two instances or that documentation is not sufficient (is there any).
I could not find any example where having two instances.

I tried it in this way (below the names and numbers are examples only)
RS485Class Dev1_RS485(Serial1, 4, 3, 2);
ModbusRTUClientClass Dev1(Dev1_RS485);

RS485Class Dev2_RS485(Serial2, 10, 11, 12); /
ModbusRTUClientClass Dev2(Dev2_RS485);

This compiles but using Dev1 or Dev2 instances does not work.
I inherited the idea from library code. If using the default ModbusRTUClient instance which is presented inside library code it works fine with Mega and DUE but I need two instances.

What does that mean? Why do you think this doesn't work? I can imagine it runs out of memory and therefor doesn't work as expected.

It does not work because the code seems to made to support one instance only.

At first I planned to fix the code but library is quite messy and it has some basic problems too. it is not actually made for Modbus because it does not have functions to access the typical data types used by Modbus devices. Of course it is quite easy to make them but this tells about the library.
Libarary has only the traditional single bit and 16bit register types supported while in pretty much every modern device has signed and unsigned 16, 32 and 64bit types as well on top of the basic 16bit registers. Also the string type is not supported as such even though it is used typically for the serial number and firmware version information.

Finally I decided to use two different libraries. One for client and onw for master.

I haven't found any hint in that direction yet. Why do you think that?

I'm quite sure this isn't true. What data types do you miss that a Modbus device should support?

But that stuff isn't part of the Modbus standard and every device manufacturer implements it's own version if it needs such support. You can only hope that he documents that otherwise you'll be surprised when you have to adapt to it.

I've seen quite a few Modbus devices but I found only one device yet to have a string output to Modbus. So expect that feature to be used extremely seldom and definitely not worth supporting it in a general Modbus library.

Might make sense, especially if you're using an AVR Arduino.