def set_buffer(library, session, mask, size):
    """Set the size for the formatted I/O and/or low-level I/O communication buffer(s).

    Corresponds to viSetBuf function of the VISA library.

    Parameters
    ----------
    library : ctypes.WinDLL or ctypes.CDLL
        ctypes wrapped library.
    session : VISASession
        Unique logical identifier to a session.
    mask : constants.BufferType
        Specifies the type of buffer.
    size : int
        The size to be set for the specified buffer(s).

    Returns
    -------
    constants.StatusCode
        Return value of the library call.

    """
    return library.viSetBuf(session, mask, size)