github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/petri/plugin/helper.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package plugin 15 16 import ( 17 "strings" 18 "unsafe" 19 ) 20 21 // DeclareAuditManifest declares manifest as AuditManifest. 22 func DeclareAuditManifest(m *Manifest) *AuditManifest { 23 return (*AuditManifest)(unsafe.Pointer(m)) 24 } 25 26 // DeclareAuthenticationManifest declares manifest as AuthenticationManifest. 27 func DeclareAuthenticationManifest(m *Manifest) *AuthenticationManifest { 28 return (*AuthenticationManifest)(unsafe.Pointer(m)) 29 } 30 31 // DeclareSchemaManifest declares manifest as SchemaManifest. 32 func DeclareSchemaManifest(m *Manifest) *SchemaManifest { 33 return (*SchemaManifest)(unsafe.Pointer(m)) 34 } 35 36 // DeclareDaemonManifest declares manifest as DaemonManifest. 37 func DeclareDaemonManifest(m *Manifest) *DaemonManifest { 38 return (*DaemonManifest)(unsafe.Pointer(m)) 39 } 40 41 // ID present plugin identity. 42 type ID string 43 44 // Decode decodes a plugin id into name, version parts. 45 func (n ID) Decode() (name string, version string, err error) { 46 splits := strings.Split(string(n), "-") 47 if len(splits) != 2 { 48 err = errInvalidPluginID.GenWithStackByArgs(string(n)) 49 return 50 } 51 name = splits[0] 52 version = splits[1] 53 return 54 }