package writers import ( "StoreBackEnd/pkg/protocol" ) // SendErrorRulePrefix Rule command prefix const SendErrorRulePrefix = "SEND_ERROR" // SendErrorRule Storage structure for the SendErrorRule type SendErrorRule struct { // cmd Rule name cmd string // matcher Allow to make a regex match matcher *protocol.RegexMatcher } // CreateSendErrorRule Creating an instance of SendErrorRule func CreateSendErrorRule(pattern string) protocol.IProtocolWriter { return &SendErrorRule{ cmd: SendErrorRulePrefix, matcher: protocol.CreateRegexMatcher(pattern), } } // GetCmd retrieve the command name. func (rule SendErrorRule) GetCmd() string { return rule.cmd } // Execute the Rule with a string command. func (rule SendErrorRule) Execute(argsData ...string) *protocol.ProtocolWriterResult { buildedCmd, _ := rule.matcher.Build(SendErrorRulePrefix, argsData...) return &protocol.ProtocolWriterResult{ Cmd: buildedCmd, } } /* func onWrite(writer *bufio.Writer) { println("Ecriture du fichier sur le réseau") } */