aboutsummaryrefslogtreecommitdiffsponsor
path: root/internal/service/mirror.go
blob: 12aaa792ec5bc114409c402ca1fad240c6ab5f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package service

import (
	"bytes"

	"git.server.ky/slackcoder/mirror/internal"
	"github.com/BurntSushi/toml"
)

type Mirror struct {
	Method      string        `toml:"method,omitempty"`
	From        *internal.URL `toml:"from,omitempty"`
	To          *internal.URL `toml:"to,omitempty"`
	Description string        `toml:"description,omitempty"`
}

func (m *Mirror) Equal(arg *Mirror) bool {
	return m.Method == arg.Method && m.From.String() == arg.From.String() && m.To.String() == arg.To.String()
}

func (m *Mirror) String() string {
	var buf bytes.Buffer

	toml.NewEncoder(&buf).Encode(m)

	return buf.String()
}