Removed unecessary function and chaged GetRID() name to RID()

This commit is contained in:
Maciej Krzyżanowski 2024-03-25 22:29:19 +01:00
parent 6c598b2c3b
commit b02b35e7e0

View File

@ -35,7 +35,7 @@ func RequestFrameFrom(req Request) (RequestFrame, error) {
return *new(RequestFrame), err return *new(RequestFrame), err
} }
return RequestFrame{req.GetRID(), jsonBytes}, nil return RequestFrame{req.RID(), jsonBytes}, nil
} }
func RequestFromFrame[T Request](reqFrame RequestFrame) (T, error) { func RequestFromFrame[T Request](reqFrame RequestFrame) (T, error) {
@ -61,7 +61,7 @@ func ResponseFrameFrom(res Response) (ResponseFrame, error) {
return *new(ResponseFrame), err return *new(ResponseFrame), err
} }
return ResponseFrame{res.GetRID(), jsonBytes}, nil return ResponseFrame{res.RID(), jsonBytes}, nil
} }
func ResponseFromFrame[T Response](resFrame ResponseFrame) (T, error) { func ResponseFromFrame[T Response](resFrame ResponseFrame) (T, error) {
@ -76,7 +76,7 @@ func ResponseFromFrame[T Response](resFrame ResponseFrame) (T, error) {
} }
type Request interface { type Request interface {
GetRID() int RID() int
} }
type Response Request type Response Request
@ -85,7 +85,7 @@ type EchoRequest struct {
EchoByte byte `json:"echoByte"` EchoByte byte `json:"echoByte"`
} }
func (EchoRequest) GetRID() int { func (EchoRequest) RID() int {
return EchoRID return EchoRID
} }
@ -93,14 +93,14 @@ type EchoResponse struct {
EchoByte byte `json:"echoByte"` EchoByte byte `json:"echoByte"`
} }
func (EchoResponse) GetRID() int { func (EchoResponse) RID() int {
return EchoRID return EchoRID
} }
type ListPeersRequest struct { type ListPeersRequest struct {
} }
func (ListPeersRequest) GetRID() int { func (ListPeersRequest) RID() int {
return ListPeersRID return ListPeersRID
} }
@ -108,7 +108,7 @@ type ListPeersResponse struct {
PeersInfo []PeerInfo `json:"peers"` PeersInfo []PeerInfo `json:"peers"`
} }
func (ListPeersResponse) GetRID() int { func (ListPeersResponse) RID() int {
return ListPeersRID return ListPeersRID
} }
@ -117,18 +117,7 @@ type AuthRequest struct {
Password string `json:"password"` Password string `json:"password"`
} }
func (req AuthRequest) MarshalJSON() ([]byte, error) { func (AuthRequest) RID() int {
type Alias AuthRequest
return json.Marshal(&struct {
ID int `json:"id"`
Alias
}{
AuthRID,
Alias(req),
})
}
func (AuthRequest) GetRID() int {
return AuthRID return AuthRID
} }
@ -136,6 +125,6 @@ type AuthResponse struct {
IsSuccess bool IsSuccess bool
} }
func (AuthResponse) GetRID() int { func (AuthResponse) RID() int {
return AuthRID return AuthRID
} }